Java Code Examples for io.prestosql.spi.connector.SchemaTableName#getSchemaName()
The following examples show how to use
io.prestosql.spi.connector.SchemaTableName#getSchemaName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public RedisTableHandle getTableHandle(ConnectorSession session, SchemaTableName schemaTableName) { RedisTableDescription table = getDefinedTables().get(schemaTableName); if (table == null) { return null; } // check if keys are supplied in a zset // via the table description doc String keyName = null; if (table.getKey() != null) { keyName = table.getKey().getName(); } return new RedisTableHandle( schemaTableName.getSchemaName(), schemaTableName.getTableName(), getDataFormat(table.getKey()), getDataFormat(table.getValue()), keyName); }
Example 2
Source File: RedisTestUtils.java From presto with Apache License 2.0 | 6 votes |
public static Map.Entry<SchemaTableName, RedisTableDescription> loadTpchTableDescription( JsonCodec<RedisTableDescription> tableDescriptionJsonCodec, SchemaTableName schemaTableName, String dataFormat) throws IOException { RedisTableDescription tpchTemplate; try (InputStream data = RedisTestUtils.class.getResourceAsStream(format("/tpch/%s/%s.json", dataFormat, schemaTableName.getTableName()))) { tpchTemplate = tableDescriptionJsonCodec.fromJson(ByteStreams.toByteArray(data)); } RedisTableDescription tableDescription = new RedisTableDescription( schemaTableName.getTableName(), schemaTableName.getSchemaName(), tpchTemplate.getKey(), tpchTemplate.getValue()); return new AbstractMap.SimpleImmutableEntry<>(schemaTableName, tableDescription); }
Example 3
Source File: AtopMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { requireNonNull(tableName, "tableName is null"); String schemaName = tableName.getSchemaName(); if (!listSchemaNames(session).contains(schemaName)) { return null; } try { AtopTable table = AtopTable.valueOf(tableName.getTableName().toUpperCase()); return new AtopTableHandle(schemaName, table); } catch (IllegalArgumentException e) { return null; } }
Example 4
Source File: AccumuloMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorNewTableLayout> layout) { checkNoRollback(); SchemaTableName tableName = tableMetadata.getTable(); AccumuloTable table = client.createTable(tableMetadata); AccumuloTableHandle handle = new AccumuloTableHandle( tableName.getSchemaName(), tableName.getTableName(), table.getRowId(), table.isExternal(), table.getSerializerClassName(), table.getScanAuthorizations()); setRollback(() -> rollbackCreateTable(table)); return handle; }
Example 5
Source File: BaseJdbcClient.java From presto with Apache License 2.0 | 6 votes |
protected void renameTable(JdbcIdentity identity, String catalogName, String schemaName, String tableName, SchemaTableName newTable) { try (Connection connection = connectionFactory.openConnection(identity)) { String newSchemaName = newTable.getSchemaName(); String newTableName = newTable.getTableName(); if (connection.getMetaData().storesUpperCaseIdentifiers()) { newSchemaName = newSchemaName.toUpperCase(ENGLISH); newTableName = newTableName.toUpperCase(ENGLISH); } String sql = format( "ALTER TABLE %s RENAME TO %s", quoted(catalogName, schemaName, tableName), quoted(catalogName, newSchemaName, newTableName)); execute(connection, sql); } catch (SQLException e) { throw new PrestoException(JDBC_ERROR, e); } }
Example 6
Source File: KinesisMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public KinesisTableHandle getTableHandle(ConnectorSession session, SchemaTableName schemaTableName) { KinesisStreamDescription table = tableDescriptionSupplier.get().get(schemaTableName); if (table == null) { throw new TableNotFoundException(schemaTableName); } return new KinesisTableHandle( schemaTableName.getSchemaName(), schemaTableName.getTableName(), table.getStreamName(), getDataFormat(table.getMessage())); }
Example 7
Source File: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
public KuduTable openTable(SchemaTableName schemaTableName) { String rawName = schemaEmulation.toRawName(schemaTableName); try { return client.openTable(rawName); } catch (KuduException e) { log.debug("Error on doOpenTable: " + e, e); if (!listSchemaNames().contains(schemaTableName.getSchemaName())) { throw new SchemaNotFoundException(schemaTableName.getSchemaName()); } throw new TableNotFoundException(schemaTableName); } }
Example 8
Source File: PinotMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public PinotTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { if (tableName.getTableName().trim().startsWith("select ")) { DynamicTable dynamicTable = DynamicTableBuilder.buildFromPql(this, tableName); return new PinotTableHandle(tableName.getSchemaName(), dynamicTable.getTableName(), TupleDomain.all(), OptionalLong.empty(), Optional.of(dynamicTable)); } return new PinotTableHandle(tableName.getSchemaName(), tableName.getTableName()); }
Example 9
Source File: SheetsMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public SheetsTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { requireNonNull(tableName, "tableName is null"); if (!listSchemaNames(session).contains(tableName.getSchemaName())) { return null; } Optional<SheetsTable> table = sheetsClient.getTable(tableName.getTableName()); if (table.isEmpty()) { return null; } return new SheetsTableHandle(tableName.getSchemaName(), tableName.getTableName()); }
Example 10
Source File: PulsarMetadata.java From pulsar with Apache License 2.0 | 5 votes |
@Override public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { return new PulsarTableHandle( this.connectorId, tableName.getSchemaName(), tableName.getTableName(), tableName.getTableName()); }
Example 11
Source File: PrometheusMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public PrometheusTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { if (!listSchemaNames(session).contains(tableName.getSchemaName())) { return null; } if (prometheusClient.getTable(tableName.getSchemaName(), tableName.getTableName()) == null) { return null; } return new PrometheusTableHandle(tableName.getSchemaName(), tableName.getTableName()); }
Example 12
Source File: HiveMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public HiveTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { requireNonNull(tableName, "tableName is null"); if (!filterSchema(tableName.getSchemaName())) { return null; } Optional<Table> table = metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName()); if (table.isEmpty()) { return null; } if (isDeltaLakeTable(table.get())) { throw new PrestoException(HIVE_UNSUPPORTED_FORMAT, "Cannot query Delta Lake table"); } // we must not allow system tables due to how permissions are checked in SystemTableAwareAccessControl if (getSourceTableNameFromSystemTable(tableName).isPresent()) { throw new PrestoException(HIVE_INVALID_METADATA, "Unexpected table present in Hive metastore: " + tableName); } verifyOnline(tableName, Optional.empty(), getProtectMode(table.get()), table.get().getParameters()); return new HiveTableHandle( tableName.getSchemaName(), tableName.getTableName(), table.get().getParameters(), getPartitionKeyColumnHandles(table.get(), typeManager), getHiveBucketHandle(table.get(), typeManager)); }
Example 13
Source File: DruidJdbcClient.java From presto with Apache License 2.0 | 5 votes |
@Override public Optional<JdbcTableHandle> getTableHandle(JdbcIdentity identity, SchemaTableName schemaTableName) { try (Connection connection = connectionFactory.openConnection(identity)) { String jdbcSchemaName = schemaTableName.getSchemaName(); String jdbcTableName = schemaTableName.getTableName(); try (ResultSet resultSet = getTables(connection, Optional.of(jdbcSchemaName), Optional.of(jdbcTableName))) { List<JdbcTableHandle> tableHandles = new ArrayList<>(); while (resultSet.next()) { tableHandles.add(new JdbcTableHandle( schemaTableName, DRUID_CATALOG, resultSet.getString("TABLE_SCHEM"), resultSet.getString("TABLE_NAME"))); } if (tableHandles.isEmpty()) { return Optional.empty(); } return Optional.of( getOnlyElement( tableHandles .stream() .filter( jdbcTableHandle -> Objects.equals(jdbcTableHandle.getSchemaName(), schemaTableName.getSchemaName()) && Objects.equals(jdbcTableHandle.getTableName(), schemaTableName.getTableName())) .collect(Collectors.toList()))); } } catch (SQLException e) { throw new PrestoException(JDBC_ERROR, e); } }
Example 14
Source File: RedisTestUtils.java From presto with Apache License 2.0 | 5 votes |
public static Map.Entry<SchemaTableName, RedisTableDescription> createEmptyTableDescription(SchemaTableName schemaTableName) { RedisTableDescription tableDescription = new RedisTableDescription( schemaTableName.getTableName(), schemaTableName.getSchemaName(), null, null); return new AbstractMap.SimpleImmutableEntry<>(schemaTableName, tableDescription); }
Example 15
Source File: ExampleMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public ExampleTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { if (!listSchemaNames(session).contains(tableName.getSchemaName())) { return null; } ExampleTable table = exampleClient.getTable(tableName.getSchemaName(), tableName.getTableName()); if (table == null) { return null; } return new ExampleTableHandle(tableName.getSchemaName(), tableName.getTableName()); }
Example 16
Source File: ThriftTableHandle.java From presto with Apache License 2.0 | 4 votes |
public ThriftTableHandle(SchemaTableName schemaTableName) { this(schemaTableName.getSchemaName(), schemaTableName.getTableName(), TupleDomain.all(), Optional.empty()); }
Example 17
Source File: PrestoThriftSchemaTableName.java From presto with Apache License 2.0 | 4 votes |
public PrestoThriftSchemaTableName(SchemaTableName schemaTableName) { this(schemaTableName.getSchemaName(), schemaTableName.getTableName()); }
Example 18
Source File: TestPushProjectionIntoTableScan.java From presto with Apache License 2.0 | 4 votes |
private Optional<ProjectionApplicationResult<ConnectorTableHandle>> mockApplyProjection( ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorExpression> projections, Map<String, ColumnHandle> assignments) { // Prepare new table handle SchemaTableName inputSchemaTableName = ((MockConnectorTableHandle) tableHandle).getTableName(); SchemaTableName projectedTableName = new SchemaTableName( inputSchemaTableName.getSchemaName(), "projected_" + inputSchemaTableName.getTableName()); MockConnectorTableHandle newTableHandle = new MockConnectorTableHandle(projectedTableName); // Prepare new column handles ImmutableList.Builder<ConnectorExpression> outputExpressions = ImmutableList.builder(); ImmutableList.Builder<Assignment> outputAssignments = ImmutableList.builder(); for (ConnectorExpression projection : projections) { String variablePrefix; if (projection instanceof Variable) { variablePrefix = "projected_variable_"; } else if (projection instanceof FieldDereference) { variablePrefix = "projected_dereference_"; } else if (projection instanceof Constant) { variablePrefix = "projected_constant_"; } else { throw new UnsupportedOperationException(); } String newVariableName = variablePrefix + projection.toString(); Variable newVariable = new Variable(newVariableName, projection.getType()); ColumnHandle newColumnHandle = new TpchColumnHandle(newVariableName, projection.getType()); outputExpressions.add(newVariable); outputAssignments.add(new Assignment(newVariableName, newColumnHandle, projection.getType())); } return Optional.of(new ProjectionApplicationResult<>(newTableHandle, outputExpressions.build(), outputAssignments.build())); }
Example 19
Source File: HiveMetadata.java From presto with Apache License 2.0 | 4 votes |
SchemaTableName getSourceTableName(SchemaTableName table) { return new SchemaTableName( table.getSchemaName(), table.getTableName().substring(0, table.getTableName().length() - suffix.length())); }
Example 20
Source File: HiveMetadata.java From presto with Apache License 2.0 | 4 votes |
@Override public HiveOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorNewTableLayout> layout) { verifyJvmTimeZone(); Optional<Path> externalLocation = Optional.ofNullable(getExternalLocation(tableMetadata.getProperties())) .map(HiveMetadata::getExternalLocationAsPath); if (!createsOfNonManagedTablesEnabled && externalLocation.isPresent()) { throw new PrestoException(NOT_SUPPORTED, "Creating non-managed Hive tables is disabled"); } if (!writesToNonManagedTablesEnabled && externalLocation.isPresent()) { throw new PrestoException(NOT_SUPPORTED, "Writes to non-managed Hive tables is disabled"); } if (getAvroSchemaUrl(tableMetadata.getProperties()) != null) { throw new PrestoException(NOT_SUPPORTED, "CREATE TABLE AS not supported when Avro schema url is set"); } HiveStorageFormat tableStorageFormat = getHiveStorageFormat(tableMetadata.getProperties()); List<String> partitionedBy = getPartitionedBy(tableMetadata.getProperties()); Optional<HiveBucketProperty> bucketProperty = getBucketProperty(tableMetadata.getProperties()); // get the root directory for the database SchemaTableName schemaTableName = tableMetadata.getTable(); String schemaName = schemaTableName.getSchemaName(); String tableName = schemaTableName.getTableName(); Map<String, String> tableProperties = getEmptyTableProperties(tableMetadata, bucketProperty, new HdfsContext(session, schemaName, tableName)); List<HiveColumnHandle> columnHandles = getColumnHandles(tableMetadata, ImmutableSet.copyOf(partitionedBy)); HiveStorageFormat partitionStorageFormat = isRespectTableFormat(session) ? tableStorageFormat : getHiveStorageFormat(session); // unpartitioned tables ignore the partition storage format HiveStorageFormat actualStorageFormat = partitionedBy.isEmpty() ? tableStorageFormat : partitionStorageFormat; actualStorageFormat.validateColumns(columnHandles); Map<String, HiveColumnHandle> columnHandlesByName = Maps.uniqueIndex(columnHandles, HiveColumnHandle::getName); List<Column> partitionColumns = partitionedBy.stream() .map(columnHandlesByName::get) .map(column -> new Column(column.getName(), column.getHiveType(), column.getComment())) .collect(toList()); checkPartitionTypesSupported(partitionColumns); LocationHandle locationHandle = locationService.forNewTable(metastore, session, schemaName, tableName, externalLocation); HiveOutputTableHandle result = new HiveOutputTableHandle( schemaName, tableName, columnHandles, metastore.generatePageSinkMetadata(new HiveIdentity(session), schemaTableName), locationHandle, tableStorageFormat, partitionStorageFormat, partitionedBy, bucketProperty, session.getUser(), tableProperties, externalLocation.isPresent()); WriteInfo writeInfo = locationService.getQueryWriteInfo(locationHandle); metastore.declareIntentionToWrite(session, writeInfo.getWriteMode(), writeInfo.getWritePath(), schemaTableName); return result; }