/** * Get a prefix of column partition path. For example, consider a column partition (col1, col2). * Then, you will get a string 'col1='. * * @param partitionColumn the schema of column partition * @return The first part string of column partition path. */ public static String getColumnPartitionPathPrefix(Schema partitionColumn) { StringBuilder sb = new StringBuilder(); sb.append(partitionColumn.getColumn(0).getSimpleName()).append("="); return sb.toString(); }
/** * Get a prefix of column partition path. For example, consider a column partition (col1, col2). * Then, you will get a string 'col1='. * * @param partitionColumn the schema of column partition * @return The first part string of column partition path. */ public static String getColumnPartitionPathPrefix(Schema partitionColumn) { StringBuilder sb = new StringBuilder(); sb.append(partitionColumn.getColumn(0).getSimpleName()).append("="); return sb.toString(); }
public static Column[] getIndexColumns(Schema tableSchema, KeyValueSet tableProperty) throws IOException, TajoException { List<Column> indexColumns = new ArrayList<>(); ColumnMapping columnMapping = new ColumnMapping(tableSchema, tableProperty); boolean[] isRowKeys = columnMapping.getIsRowKeyMappings(); for (int i = 0; i < isRowKeys.length; i++) { if (isRowKeys[i]) { indexColumns.add(tableSchema.getColumn(i)); } } return indexColumns.toArray(new Column[indexColumns.size()]); }
@Override public String getColumnTypeName(int column) throws SQLException { DataType type = schema.getColumn(column - 1).getDataType(); return ResultSetUtil.toSqlType(type); }
@Override public int getColumnType(int column) throws SQLException { DataType type = schema.getColumn(column - 1).getDataType(); return ResultSetUtil.tajoTypeToSqlType(type); }
@Override public String getColumnTypeName(int column) throws SQLException { DataType type = schema.getColumn(column - 1).getDataType(); return ResultSetUtil.toSqlType(type); }
private static TupleType[] tupleTypes(Schema schema, int[] keyIndex) { TupleType[] types = new TupleType[keyIndex.length]; for (int i = 0; i < keyIndex.length; i++) { types[i] = tupleType(schema.getColumn(keyIndex[i]).getDataType().getType()); } return types; }
public static DataType [] toDataTypes(Schema schema) { DataType[] types = new DataType[schema.size()]; for (int i = 0; i < schema.size(); i++) { types[i] = schema.getColumn(i).getDataType(); } return types; }
@Override public boolean isSigned(int column) throws SQLException { DataType type = schema.getColumn(column - 1).getDataType(); return TajoTypeUtil.isSigned(type.getType()); }
public static String [] toSimpleNames(Schema schema) { String [] names = new String[schema.size()]; for (int i = 0; i < schema.size(); i++) { names[i] = schema.getColumn(i).getSimpleName(); } return names; }
@Override public boolean isSigned(int column) throws SQLException { DataType type = schema.getColumn(column - 1).getDataType(); return TajoTypeUtil.isSigned(type.getType()); }
public static DataType [] toDataTypes(Schema schema) { DataType[] types = new DataType[schema.size()]; for (int i = 0; i < schema.size(); i++) { types[i] = schema.getColumn(i).getDataType(); } return types; }
private static TupleType[] tupleTypes(Schema schema, int[] keyIndex) { TupleType[] types = new TupleType[keyIndex.length]; for (int i = 0; i < keyIndex.length; i++) { types[i] = tupleType(schema.getColumn(keyIndex[i]).getDataType().getType()); } return types; }
public static Type [] toTypes(Schema schema) { Type [] types = new Type[schema.size()]; for (int i = 0; i < schema.size(); i++) { types[i] = schema.getColumn(i).getDataType().getType(); } return types; }
public static Target[] schemaToTargets(Schema schema) { Target[] targets = new Target[schema.size()]; FieldEval eval; for (int i = 0; i < schema.size(); i++) { eval = new FieldEval(schema.getColumn(i)); targets[i] = new Target(eval); } return targets; }
@Override public String getCatalogName(int column) throws SQLException { Column c = schema.getColumn(column - 1); if (CatalogUtil.isFQColumnName(c.getQualifiedName())) { return CatalogUtil.splitFQTableName(c.getQualifier())[0]; } return ""; }
@Override public String getCatalogName(int column) throws SQLException { Column c = schema.getColumn(column - 1); if (IdentifierUtil.isFQColumnName(c.getQualifiedName())) { return IdentifierUtil.splitFQTableName(c.getQualifier())[0]; } return ""; }
public TableStatistics(Schema schema, boolean[] columnStatsEnabled) { this.schema = schema; minValues = new VTuple(schema.size()); maxValues = new VTuple(schema.size()); numNulls = new long[schema.size()]; this.columnStatsEnabled = columnStatsEnabled; for (int i = 0; i < schema.size(); i++) { if (schema.getColumn(i).getDataType().getType().equals(Type.PROTOBUF)) { columnStatsEnabled[i] = false; } } }
public TableStatistics(Schema schema, boolean[] columnStatsEnabled) { this.schema = schema; minValues = new VTuple(schema.size()); maxValues = new VTuple(schema.size()); numNulls = new long[schema.size()]; this.columnStatsEnabled = columnStatsEnabled; for (int i = 0; i < schema.size(); i++) { if (schema.getColumn(i).getDataType().getType().equals(Type.PROTOBUF)) { columnStatsEnabled[i] = false; } } }
public static void assertSchema(Schema expected, Schema schema) { Column expectedColumn; Column column; for (int i = 0; i < expected.size(); i++) { expectedColumn = expected.getColumn(i); column = schema.getColumn(expectedColumn.getSimpleName()); assertEquals(expectedColumn.getSimpleName(), column.getSimpleName()); assertEquals(expectedColumn.getDataType(), column.getDataType()); } }