com.teradata.tpcds.column.Column Java Examples
The following examples show how to use
com.teradata.tpcds.column.Column.
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: TPCDSUtils.java From aws-athena-query-federation with Apache License 2.0 | 6 votes |
/** * Converts from TPCDS columns to Apache Arrow fields. * * @param column The TPCDS column to conver. * @return The Apache Arrow field that corresponds to the TPCDS column. */ public static Field convertColumn(Column column) { ColumnType type = column.getType(); switch (type.getBase()) { case TIME: case IDENTIFIER: return FieldBuilder.newBuilder(column.getName(), Types.MinorType.BIGINT.getType()).build(); case INTEGER: return FieldBuilder.newBuilder(column.getName(), Types.MinorType.INT.getType()).build(); case DATE: return FieldBuilder.newBuilder(column.getName(), Types.MinorType.DATEDAY.getType()).build(); case DECIMAL: ArrowType arrowType = new ArrowType.Decimal(type.getPrecision().get(), type.getScale().get()); return FieldBuilder.newBuilder(column.getName(), arrowType).build(); case CHAR: case VARCHAR: return FieldBuilder.newBuilder(column.getName(), Types.MinorType.VARCHAR.getType()).build(); } throw new IllegalArgumentException("Unsupported TPC-DS type " + column.getName() + ":" + column.getType().getBase()); }
Example #2
Source File: TPCDSRecordHandler.java From aws-athena-query-federation with Apache License 2.0 | 6 votes |
/** * Generates the CellWriters used to convert the TPCDS Generators data to Apache Arrow. * * @param schemaForRead The schema to read/project. * @param table The TPCDS Table we are reading from. * @return Map<Integer, CellWriter> where integer is the Column position in the TPCDS data set and the CellWriter * can be used to read,convert,write the value at that position for any row into the correct position and type * in our Apache Arrow response. */ private Map<Integer, CellWriter> makeWriters(Schema schemaForRead, Table table) { Map<String, Column> columnPositions = new HashMap<>(); for (Column next : table.getColumns()) { columnPositions.put(next.getName(), next); } //We use this approach to reduce the overhead of field lookups. This isn't as good as true columnar processing //using Arrow but it gets us ~80% of the way there from a rows/second per cpu-cycle perspective. Map<Integer, CellWriter> writers = new HashMap<>(); for (Field nextField : schemaForRead.getFields()) { Column column = columnPositions.get(nextField.getName()); writers.put(column.getPosition(), makeWriter(nextField, column)); } return writers; }
Example #3
Source File: TPCDSMetadataHandler.java From aws-athena-query-federation with Apache License 2.0 | 6 votes |
/** * Used to get definition (field names, types, descriptions, etc...) of a Table using the static * metadata provided by TerraData's TPCDS generator. * * @see MetadataHandler */ @Override public GetTableResponse doGetTable(BlockAllocator allocator, GetTableRequest request) { logger.info("doGetTable: enter - " + request); Table table = TPCDSUtils.validateTable(request.getTableName()); SchemaBuilder schemaBuilder = SchemaBuilder.newBuilder(); for (Column nextCol : table.getColumns()) { schemaBuilder.addField(TPCDSUtils.convertColumn(nextCol)); } return new GetTableResponse(request.getCatalogName(), request.getTableName(), schemaBuilder.build(), Collections.EMPTY_SET); }
Example #4
Source File: TpcdsSchema.java From calcite with Apache License 2.0 | 6 votes |
private static Object convert(String string, Column column) { if (string == null) { return null; } switch (column.getType().getBase()) { case IDENTIFIER: return Long.valueOf(string); case INTEGER: return Integer.valueOf(string); case CHAR: case VARCHAR: return string; case DATE: return DateTimeUtils.dateStringToUnixDate(string); case TIME: return DateTimeUtils.timeStringToUnixDate(string); case DECIMAL: return new BigDecimal(string); default: throw new AssertionError(column); } }
Example #5
Source File: TpcdsSchema.java From calcite with Apache License 2.0 | 5 votes |
public <T> Queryable<T> asQueryable(final QueryProvider queryProvider, final SchemaPlus schema, final String tableName) { //noinspection unchecked return (Queryable) new AbstractTableQueryable<Object[]>(queryProvider, schema, this, tableName) { public Enumerator<Object[]> enumerator() { final Session session = Session.getDefaultSession() .withTable(tpcdsTable) .withScale(scaleFactor); final Results results = Results.constructResults(tpcdsTable, session); return Linq4j.asEnumerable(results) .selectMany( new Function1<List<List<String>>, Enumerable<Object[]>>() { final Column[] columns = tpcdsTable.getColumns(); public Enumerable<Object[]> apply( List<List<String>> inRows) { final List<Object[]> rows = new ArrayList<>(); for (List<String> strings : inRows) { final Object[] values = new Object[columns.length]; for (int i = 0; i < strings.size(); i++) { values[i] = convert(strings.get(i), columns[i]); } rows.add(values); } return Linq4j.asEnumerable(rows); } }) .enumerator(); } }; }
Example #6
Source File: TpcdsSchema.java From calcite with Apache License 2.0 | 5 votes |
public RelDataType getRowType(RelDataTypeFactory typeFactory) { final RelDataTypeFactory.Builder builder = typeFactory.builder(); for (Column column : tpcdsTable.getColumns()) { builder.add(column.getName().toUpperCase(Locale.ROOT), type(typeFactory, column)); } return builder.build(); }