有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

创建数据集时,除字符串以外的java Quicksight输入列类型无效

当试图通过从S3存储桶导入CSV来在Quicksight中自动创建数据集时,我在尝试从Java API调用createDataSet()方法来创建数据集时出错:

com。亚马逊。服务。快看。模型InvalidParameterValueException:物理表PrimaryTable中的输入列Year的类型无效。S3物理表允许的类型为[String](服务:AmazonQuickSight;状态代码:400;错误代码:InvalidParameterValueException;请求ID:84d3da22-4e4e-45e0-8bbf-9d01975206b0;代理:null) 相关代码如下,第六列为Input。添加导致错误的行:

inputColumns.add(new InputColumn().withName("Column 1").withType(InputColumnDataType.STRING));
inputColumns.add(new InputColumn().withName("Column 2").withType(InputColumnDataType.STRING));
inputColumns.add(new InputColumn().withName("Column 3").withType(InputColumnDataType.STRING));
inputColumns.add(new InputColumn().withName("Column 4").withType(InputColumnDataType.STRING));
inputColumns.add(new InputColumn().withName("Column 5").withType(InputColumnDataType.STRING));
inputColumns.add(new InputColumn().withName("Year").withType(InputColumnDataType.INTEGER)); //*hits the error on this line*
... //more columns with types STRING, INTEGER, and DECIMAL

s3source.setDataSourceArn(QS_BASE_ARN + "datasource/" + sourceName);
s3source.setInputColumns(inputColumns);
uploadSettings.setFormat(FileFormat.CSV.name());
uploadSettings.setContainsHeader(true);
uploadSettings.setDelimiter(",");
s3source.setUploadSettings(uploadSettings);
physicalTable.setS3Source(s3source);
Map<String, PhysicalTable> physicalTableMap = new HashMap<String, PhysicalTable>();
physicalTableMap.put("PrimaryTable", physicalTable);
newDataSet.withAwsAccountId(ACCOUNT_ID).withDataSetId(dataSetId).withName(dataSetName).withPhysicalTableMap(physicalTableMap).withImportMode("SPICE"); //These are all the required parameters for the API request
permissions.add(new ResourcePermission().withPrincipal(QS_BASE_ARN + "user/default/" + username).withActions("quicksight:UpdateDataSetPermissions","quicksight:DescribeDataSet","quicksight:DescribeDataSetPermissions","quicksight:PassDataSet", "quicksight:DescribeIngestion", "quicksight:ListIngestions", "quicksight:UpdateDataSet", "quicksight:DeleteDataSet","quicksight:CreateIngestion","quicksight:CancelIngestion"));
newDataSet.setPermissions(permissions);
try {
   return getClient().createDataSet(newDataSet); //Creates SPICE dataset
} catch (SdkClientException e) {
   throw e;
}

getClient()方法为:

private static AmazonQuickSight getClient() {
   final AWSCredentialsProvider credsProvider = new AWSCredentialsProvider() {
   @Override
   public AWSCredentials getCredentials() {
      // provide actual IAM access key and secret key here
      return new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
   }
   @Override
   public void refresh() {}
   };
   return AmazonQuickSightClientBuilder
      .standard()
      .withRegion(Regions.US_EAST_1.getName())
      .withCredentials(credsProvider)
      .build();
}

API文档表示字符串|整数|十进制|日期时间|位|布尔| JSON都被接受,但是错误消息和测试表明,只有字符串被接受为类型(API文档:https://docs.aws.amazon.com/quicksight/latest/APIReference/API_InputColumn.html

这个错误是由API不接受它所说的数据类型引起的还是由我的设置引起的


共 (0) 个答案