Search in sources :

Example 1 with DBSchemaParser

use of com.thinkbiganalytics.schema.DBSchemaParser in project kylo by Teradata.

the class DBCPConnectionPoolService method describeTableForControllerService.

private TableSchema describeTableForControllerService(DescribeTableControllerServiceRequest serviceProperties) {
    String type = serviceProperties.getControllerServiceType();
    if (serviceProperties.getControllerServiceType() != null && serviceProperties.getControllerServiceType().equalsIgnoreCase(type)) {
        Map<String, String> properties = serviceProperties.useEnvironmentProperties() ? nifiControllerServiceProperties.mergeNifiAndEnvProperties(serviceProperties.getControllerServiceDTO().getProperties(), serviceProperties.getControllerServiceName()) : serviceProperties.getControllerServiceDTO().getProperties();
        PoolingDataSourceService.DataSourceProperties dataSourceProperties = getDataSourceProperties(properties, serviceProperties);
        boolean valid = evaluateWithUserDefinedDatasources(dataSourceProperties, serviceProperties);
        if (valid) {
            log.info("describing Table {}.{} against Controller Service: {} ({}) with uri of {} ", serviceProperties.getSchemaName(), serviceProperties.getTableName(), serviceProperties.getControllerServiceName(), serviceProperties.getControllerServiceId(), dataSourceProperties.getUrl());
            DataSource dataSource = PoolingDataSourceService.getDataSource(dataSourceProperties);
            DBSchemaParser schemaParser = new DBSchemaParser(dataSource, kerberosHiveConfiguration);
            return schemaParser.describeTable(serviceProperties.getSchemaName(), serviceProperties.getTableName());
        } else {
            return null;
        }
    }
    return null;
}
Also used : PoolingDataSourceService(com.thinkbiganalytics.db.PoolingDataSourceService) DBSchemaParser(com.thinkbiganalytics.schema.DBSchemaParser) DataSource(javax.sql.DataSource)

Example 2 with DBSchemaParser

use of com.thinkbiganalytics.schema.DBSchemaParser in project kylo by Teradata.

the class DBCPConnectionPoolService method getTableNamesForControllerService.

/**
 * Return a list of schema.table_name
 *
 * @param serviceProperties properties describing where and what to look for
 * @return a list of schema.table_name
 */
private List<String> getTableNamesForControllerService(DescribeTableControllerServiceRequest serviceProperties) {
    if (serviceProperties != null) {
        Map<String, String> properties = serviceProperties.useEnvironmentProperties() ? nifiControllerServiceProperties.mergeNifiAndEnvProperties(serviceProperties.getControllerServiceDTO().getProperties(), serviceProperties.getControllerServiceName()) : serviceProperties.getControllerServiceDTO().getProperties();
        PoolingDataSourceService.DataSourceProperties dataSourceProperties = getDataSourceProperties(properties, serviceProperties);
        boolean valid = evaluateWithUserDefinedDatasources(dataSourceProperties, serviceProperties);
        if (valid) {
            log.info("Search For Tables against Controller Service: {} ({}) with uri of {}.  ", serviceProperties.getControllerServiceName(), serviceProperties.getControllerServiceId(), dataSourceProperties.getUrl());
            DataSource dataSource = PoolingDataSourceService.getDataSource(dataSourceProperties);
            DBSchemaParser schemaParser = new DBSchemaParser(dataSource, kerberosHiveConfiguration);
            return schemaParser.listTables(serviceProperties.getSchemaName());
        }
    }
    return null;
}
Also used : PoolingDataSourceService(com.thinkbiganalytics.db.PoolingDataSourceService) DBSchemaParser(com.thinkbiganalytics.schema.DBSchemaParser) DataSource(javax.sql.DataSource)

Example 3 with DBSchemaParser

use of com.thinkbiganalytics.schema.DBSchemaParser in project kylo by Teradata.

the class DBCPConnectionPoolService method getSchemaNamesForControllerService.

/**
 * Return a list of schema.table_name
 *
 * @param serviceProperties properties describing where and what to look for
 * @return a list of schema.table_name
 */
private List<String> getSchemaNamesForControllerService(DescribeTableControllerServiceRequest serviceProperties) {
    if (serviceProperties != null) {
        Map<String, String> properties = serviceProperties.useEnvironmentProperties() ? nifiControllerServiceProperties.mergeNifiAndEnvProperties(serviceProperties.getControllerServiceDTO().getProperties(), serviceProperties.getControllerServiceName()) : serviceProperties.getControllerServiceDTO().getProperties();
        PoolingDataSourceService.DataSourceProperties dataSourceProperties = getDataSourceProperties(properties, serviceProperties);
        boolean valid = evaluateWithUserDefinedDatasources(dataSourceProperties, serviceProperties);
        if (valid) {
            log.info("Search For Tables against Controller Service: {} ({}) with uri of {}.  ", serviceProperties.getControllerServiceName(), serviceProperties.getControllerServiceId(), dataSourceProperties.getUrl());
            DataSource dataSource = PoolingDataSourceService.getDataSource(dataSourceProperties);
            DBSchemaParser schemaParser = new DBSchemaParser(dataSource, kerberosHiveConfiguration);
            return schemaParser.listSchemasOrCatalogs();
        }
    }
    return null;
}
Also used : PoolingDataSourceService(com.thinkbiganalytics.db.PoolingDataSourceService) DBSchemaParser(com.thinkbiganalytics.schema.DBSchemaParser) DataSource(javax.sql.DataSource)

Aggregations

PoolingDataSourceService (com.thinkbiganalytics.db.PoolingDataSourceService)3 DBSchemaParser (com.thinkbiganalytics.schema.DBSchemaParser)3 DataSource (javax.sql.DataSource)3