use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class RedshiftMetadataHandlerTest method doGetTableWithArrayColumns.
@Test
public void doGetTableWithArrayColumns() throws Exception {
logger.info("doGetTableWithArrayColumns - enter");
String[] schema = { "DATA_TYPE", "COLUMN_NAME", "COLUMN_SIZE", "DECIMAL_DIGITS", "TYPE_NAME" };
Object[][] values = { { Types.ARRAY, "bool_array", 0, 0, "_bool" }, { Types.ARRAY, "smallint_array", 0, 0, "_int2" }, { Types.ARRAY, "int_array", 0, 0, "_int4" }, { Types.ARRAY, "bigint_array", 0, 0, "_int8" }, { Types.ARRAY, "float_array", 0, 0, "_float4" }, { Types.ARRAY, "double_array", 0, 0, "_float8" }, { Types.ARRAY, "date_array", 0, 0, "_date" }, { Types.ARRAY, "timestamp_array", 0, 0, "_timestamp" }, { Types.ARRAY, "binary_array", 0, 0, "_bytea" }, { Types.ARRAY, "decimal_array", 38, 2, "_numeric" }, { Types.ARRAY, "string_array", 0, 0, "_text" }, { Types.ARRAY, "uuid_array", 0, 0, "_uuid" } };
AtomicInteger rowNumber = new AtomicInteger(-1);
ResultSet resultSet = mockResultSet(schema, values, rowNumber);
SchemaBuilder expectedSchemaBuilder = SchemaBuilder.newBuilder();
expectedSchemaBuilder.addListField("bool_array", new ArrowType.Bool()).addListField("smallint_array", new ArrowType.Int(16, true)).addListField("int_array", new ArrowType.Int(32, true)).addListField("bigint_array", new ArrowType.Int(64, true)).addListField("float_array", new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)).addListField("double_array", new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)).addListField("date_array", new ArrowType.Date(DateUnit.DAY)).addListField("timestamp_array", new ArrowType.Date(DateUnit.MILLISECOND)).addListField("binary_array", new ArrowType.Utf8()).addListField("decimal_array", new ArrowType.Decimal(38, 2)).addListField("string_array", new ArrowType.Utf8()).addListField("uuid_array", new ArrowType.Utf8());
redshiftMetadataHandler.getPartitionSchema("testCatalog").getFields().forEach(expectedSchemaBuilder::addField);
Schema expected = expectedSchemaBuilder.build();
TableName inputTableName = new TableName("testSchema", "testTable");
Mockito.when(connection.getMetaData().getColumns("testCatalog", inputTableName.getSchemaName(), inputTableName.getTableName(), null)).thenReturn(resultSet);
Mockito.when(connection.getCatalog()).thenReturn("testCatalog");
GetTableResponse getTableResponse = this.redshiftMetadataHandler.doGetTable(new BlockAllocatorImpl(), new GetTableRequest(this.federatedIdentity, "testQueryId", "testCatalog", inputTableName));
logger.info("Schema: {}", getTableResponse.getSchema());
Assert.assertEquals(expected, getTableResponse.getSchema());
Assert.assertEquals(inputTableName, getTableResponse.getTableName());
Assert.assertEquals("testCatalog", getTableResponse.getCatalogName());
logger.info("doGetTableWithArrayColumns - exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class SynapseMuxMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
GetTableRequest getTableRequest = Mockito.mock(GetTableRequest.class);
Mockito.when(getTableRequest.getCatalogName()).thenReturn("fakedatabase");
this.jdbcMetadataHandler.doGetTable(this.allocator, getTableRequest);
Mockito.verify(this.synapseMetadataHandler, Mockito.times(1)).doGetTable(Mockito.eq(this.allocator), Mockito.eq(getTableRequest));
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class SqlServerMuxMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
GetTableRequest getTableRequest = Mockito.mock(GetTableRequest.class);
Mockito.when(getTableRequest.getCatalogName()).thenReturn("fakedatabase");
this.jdbcMetadataHandler.doGetTable(this.allocator, getTableRequest);
Mockito.verify(this.sqlServerMetadataHandler, Mockito.times(1)).doGetTable(Mockito.eq(this.allocator), Mockito.eq(getTableRequest));
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class TPCDSMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
logger.info("doGetTable - enter");
String expectedSchema = "tpcds1";
GetTableRequest req = new GetTableRequest(identity, "queryId", "default", new TableName(expectedSchema, "customer"));
GetTableResponse res = handler.doGetTable(allocator, req);
logger.info("doGetTable - {} {}", res.getTableName(), res.getSchema());
assertEquals(new TableName(expectedSchema, "customer"), res.getTableName());
assertTrue(res.getSchema() != null);
logger.info("doGetTable - exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class ExampleMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
if (!enableTests) {
// We do this because until you complete the tutorial these tests will fail. When you attempt to publis
// using ../toos/publish.sh ... it will set the publishing flag and force these tests. This is how we
// avoid breaking the build but still have a useful tutorial. We are also duplicateing this block
// on purpose since this is a somewhat odd pattern.
logger.info("doGetTable: Tests are disabled, to enable them set the 'publishing' environment variable " + "using maven clean install -Dpublishing=true");
return;
}
logger.info("doGetTable - enter");
GetTableRequest req = new GetTableRequest(fakeIdentity(), "queryId", "default", new TableName("schema1", "table1"));
GetTableResponse res = handler.doGetTable(allocator, req);
assertTrue(res.getSchema().getFields().size() > 0);
assertTrue(res.getSchema().getCustomMetadata().size() > 0);
logger.info("doGetTable - {}", res);
logger.info("doGetTable - exit");
}
Aggregations