Trouble programatically duplicating datasets

Is there an easy way to duplicate a DataSet? I’ve tried the following code but running into the following error:

Code

    private DataSet copyDataSet(DataSet source, String name){
        CreateDataSetRequest request = CreateDataSetRequest.builder()
                .awsAccountId(awsAccountId)
                .dataSetId(UUID.randomUUID().toString())
                .name(name)
                .physicalTableMap(source.physicalTableMap())
                .logicalTableMap(modifedLogicalMap(source.logicalTableMap()))
                .importMode(source.importMode())
                .columnGroups(source.columnGroups())
                .fieldFolders(source.fieldFolders())
//                .permissions()
                .rowLevelPermissionDataSet(source.rowLevelPermissionDataSet())
                .rowLevelPermissionTagConfiguration(source.rowLevelPermissionTagConfiguration())
                .columnLevelPermissionRules(source.columnLevelPermissionRules())
//                .tags()
                .dataSetUsageConfiguration(source.dataSetUsageConfiguration())
                .build();
        CreateDataSetResponse response = client.createDataSet(request);
        return describeDataSet(response.dataSetId());
    }

Error

Unable to process your request while preparing the table view from your schema, calculated columns [Days Until Lost] are invalid. ErrorType: CONTEXTUAL_UNKNOWN_SYMBOL (Service: QuickSight, Status Code: 400, Request ID: 6a1942f7-4d3b-4a56-b5dd-55073ed518a9)

I found this (What could cause CONTEXTUAL_UNKNOWN_SYMBOL error?) and its possible there is an issue with ordering of calculation fields (suspect they are depending on other fields not yet loaded)

Can someone give me some advice on how I can duplicate my DataSet?

Update: Leveraged JGraphT determine the TopologicalOrder of calculated fields based on the references it has … but now I get another error:

ErrorType: CONTEXTUAL_INVALID_ARGUMENT_TYPE (Service: QuickSight, Status Code: 400, Request ID: eee838bd-defe-4e84-bd02-8406173a1b6c)

In describe dataset I believe you need to pass in the AWS account Id as well.

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/quicksight/describe-data-set.html

Unless that describeDataSet is a function you created yourself which it looks like it is.

Yeah, the describe dataset was something I created. It does pass the awsAccountId … but the application blows up on the line before that @

CreateDataSetResponse response = client.createDataSet(request)

What language are you using?

@ccaspanello, I am using Java


  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>bom</artifactId>
        <version>2.18.20</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>quicksight</artifactId>
    </dependency>
  </dependencies>

I was able to solve this without any crazy code. We had some bad data that prevent some of the dates from validating during the copy process. This seems to be the root cause. Fixing the calculations solved our issues. Thanks

1 Like