Search in sources :

Example 36 with ColumnMetadata

use of com.datastax.driver.core.ColumnMetadata in project metacat by Netflix.

the class CassandraConnectorTableService method getTableInfo.

private TableInfo getTableInfo(@Nonnull @NonNull final QualifiedName name, @Nonnull @NonNull final TableMetadata tableMetadata) {
    final ImmutableList.Builder<FieldInfo> fieldInfoBuilder = ImmutableList.builder();
    // TODO: Ignores clustering, primary key, index, etc columns. We need to rework TableInfo to support
    for (final ColumnMetadata column : tableMetadata.getColumns()) {
        final String dataType = column.getType().toString();
        fieldInfoBuilder.add(FieldInfo.builder().name(column.getName()).sourceType(dataType).type(this.typeConverter.toMetacatType(dataType)).build());
    }
    return TableInfo.builder().name(QualifiedName.ofTable(name.getCatalogName(), name.getDatabaseName(), tableMetadata.getName())).fields(fieldInfoBuilder.build()).build();
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) ImmutableList(com.google.common.collect.ImmutableList) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo)

Example 37 with ColumnMetadata

use of com.datastax.driver.core.ColumnMetadata in project apex-malhar by apache.

the class AbstractUpsertOutputOperator method registerPrimaryKeyColumnDefinitions.

private void registerPrimaryKeyColumnDefinitions(final TableMetadata tableMetadata) {
    List<ColumnMetadata> primaryKeyColumns = tableMetadata.getPrimaryKey();
    for (ColumnMetadata primaryColumn : primaryKeyColumns) {
        columnDefinitions.put(primaryColumn.getName(), primaryColumn.getType());
        pkColumnNames.add(primaryColumn.getName());
        parseForSpecialDataType(primaryColumn);
    }
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata)

Aggregations

ColumnMetadata (com.datastax.driver.core.ColumnMetadata)37 Test (org.testng.annotations.Test)11 TableMetadata (com.datastax.driver.core.TableMetadata)8 CassandraVersion (com.datastax.driver.core.utils.CassandraVersion)8 EntityTypeMetadata (com.datastax.driver.mapping.meta.EntityTypeMetadata)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 AbstractTableMetadata (com.datastax.driver.core.AbstractTableMetadata)2 KeyspaceMetadata (com.datastax.driver.core.KeyspaceMetadata)2 ImmutableList (com.google.common.collect.ImmutableList)2 ByteBuffer (java.nio.ByteBuffer)2 BoundStatementMapper (org.simpleflatmapper.datastax.BoundStatementMapper)2 Cluster (com.datastax.driver.core.Cluster)1 DataType (com.datastax.driver.core.DataType)1 MaterializedViewMetadata (com.datastax.driver.core.MaterializedViewMetadata)1 RegularStatement (com.datastax.driver.core.RegularStatement)1 EntityWithCompositeKey (com.datastax.driver.mapping.entity.EntityWithCompositeKey)1 EntityWithIndexes (com.datastax.driver.mapping.entity.EntityWithIndexes)1 EntityWithTimeUUID (com.datastax.driver.mapping.entity.EntityWithTimeUUID)1 EntityFieldMetaData (com.datastax.driver.mapping.meta.EntityFieldMetaData)1