use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class PostGreSqlMuxJdbcMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
GetTableRequest getTableRequest = Mockito.mock(GetTableRequest.class);
Mockito.when(getTableRequest.getCatalogName()).thenReturn("postgres");
this.jdbcMetadataHandler.doGetTable(this.allocator, getTableRequest);
Mockito.verify(this.postGreSqlMetadataHandler, 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 NeptuneMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() throws Exception {
logger.info("doGetTable - enter");
Table table = new Table();
table.setName("table1");
Map<String, String> expectedParams = new HashMap<>();
expectedParams.put("sourceTable", table.getName());
expectedParams.put("columnMapping", "col2=Col2,col3=Col3, col4=Col4");
expectedParams.put("datetimeFormatMapping", "col2=someformat2, col1=someformat1 ");
table.setParameters(expectedParams);
List<Column> columns = new ArrayList<>();
columns.add(new Column().withName("col1").withType("int").withComment("comment"));
columns.add(new Column().withName("col2").withType("bigint").withComment("comment"));
columns.add(new Column().withName("col3").withType("string").withComment("comment"));
columns.add(new Column().withName("col4").withType("timestamp").withComment("comment"));
columns.add(new Column().withName("col5").withType("date").withComment("comment"));
columns.add(new Column().withName("col6").withType("timestamptz").withComment("comment"));
columns.add(new Column().withName("col7").withType("timestamptz").withComment("comment"));
StorageDescriptor storageDescriptor = new StorageDescriptor();
storageDescriptor.setColumns(columns);
table.setStorageDescriptor(storageDescriptor);
GetTableRequest req = new GetTableRequest(IDENTITY, "queryId", "default", new TableName("schema1", "table1"));
GetTableResult getTableResult = new GetTableResult();
getTableResult.setTable(table);
when(glue.getTable(any(com.amazonaws.services.glue.model.GetTableRequest.class))).thenReturn(getTableResult);
GetTableResponse res = handler.doGetTable(allocator, req);
assertTrue(res.getSchema().getFields().size() > 0);
logger.info("doGetTable - {}", res);
logger.info("doGetTable - exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class OracleMuxJdbcMetadataHandlerTest 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.oracleMetadataHandler, 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 RedshiftMuxJdbcMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
GetTableRequest getTableRequest = Mockito.mock(GetTableRequest.class);
Mockito.when(getTableRequest.getCatalogName()).thenReturn("redshift");
this.jdbcMetadataHandler.doGetTable(this.allocator, getTableRequest);
Mockito.verify(this.redshiftMetadataHandler, 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 SynapseMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() throws Exception {
Schema PARTITION_SCHEMA = SchemaBuilder.newBuilder().addField("PARTITION_NUMBER", org.apache.arrow.vector.types.Types.MinorType.VARCHAR.getType()).build();
BlockAllocator blockAllocator = new BlockAllocatorImpl();
String[] schema = { "DATA_TYPE", "COLUMN_SIZE", "COLUMN_NAME", "DECIMAL_DIGITS", "NUM_PREC_RADIX" };
Object[][] values = { { Types.INTEGER, 12, "testCol1", 0, 0 }, { Types.VARCHAR, 25, "testCol2", 0, 0 }, { Types.TIMESTAMP, 93, "testCol3", 0, 0 }, { Types.TIMESTAMP_WITH_TIMEZONE, 93, "testCol4", 0, 0 } };
AtomicInteger rowNumber = new AtomicInteger(-1);
ResultSet resultSet = mockResultSet(schema, values, rowNumber);
SchemaBuilder expectedSchemaBuilder = SchemaBuilder.newBuilder();
expectedSchemaBuilder.addField(FieldBuilder.newBuilder("testCol1", org.apache.arrow.vector.types.Types.MinorType.INT.getType()).build());
expectedSchemaBuilder.addField(FieldBuilder.newBuilder("testCol2", org.apache.arrow.vector.types.Types.MinorType.VARCHAR.getType()).build());
expectedSchemaBuilder.addField(FieldBuilder.newBuilder("testCol3", org.apache.arrow.vector.types.Types.MinorType.DATEMILLI.getType()).build());
expectedSchemaBuilder.addField(FieldBuilder.newBuilder("testCol4", org.apache.arrow.vector.types.Types.MinorType.VARCHAR.getType()).build());
PARTITION_SCHEMA.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.synapseMetadataHandler.doGetTable(blockAllocator, new GetTableRequest(this.federatedIdentity, "testQueryId", "testCatalog", inputTableName));
Assert.assertEquals(expected, getTableResponse.getSchema());
Assert.assertEquals(inputTableName, getTableResponse.getTableName());
Assert.assertEquals("testCatalog", getTableResponse.getCatalogName());
}
Aggregations