Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
wsjz committed Nov 19, 2023
1 parent 30c59fb commit dd9a1a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ protected void initTableInfo(ColumnType[] requiredTypes, String[] requiredFields
readColumnsToId.put(fields[i], i);
}
}
}

@Override
public void open() throws IOException {
// reorder columns
List<Column> columnList = curTableScan.getSchema().getColumns();
columnList.addAll(curTableScan.getSchema().getPartitionColumns());
Expand All @@ -151,10 +155,6 @@ protected void initTableInfo(ColumnType[] requiredTypes, String[] requiredFields
// Downloading columns data from Max compute only supports the order of table metadata.
// We might get an error message if no sort here: Column reorder is not supported in legacy arrow mode.
readColumns.sort((Comparator.comparing(o -> columnRank.get(o.getName()))));
}

@Override
public void open() throws IOException {
if (readColumns.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public class MaxComputeJniScannerTest {
put("partition_spec", "p1=2022-06");
put("required_fields", "boolean,tinyint,smallint,int,bigint,float,double,"
+ "date,timestamp,char,varchar,string,decimalv2,decimal64,"
+ "decimal18,timestamp4,date");
+ "decimal18,timestamp4");
put("columns_types", "boolean#tinyint#smallint#int#bigint#float#double#"
+ "date#timestamp#char(10)#varchar(10)#string#decimalv2(12,4)#decimal64(10,3)#"
+ "decimal(18,5)#timestamp(4)#date");
+ "decimal(18,5)#timestamp(4)");
}
};
private MaxComputeJniScanner scanner = new MaxComputeJniScanner(32, paramsMc);
Expand All @@ -70,6 +70,11 @@ public TableSchema getSchema() {
}
};
new MockUp<MaxComputeTableScan>(MaxComputeTableScan.class) {
@Mock
public TableSchema getSchema() {
return getTestSchema();
}

@Mock
public TableTunnel.DownloadSession openDownLoadSession() throws IOException {
return session;
Expand Down Expand Up @@ -102,8 +107,25 @@ public ArrowRecordReader openArrowRecordReader(long start, long count, List<Colu

private TableSchema getTestSchema() {
TableSchema schema = new TableSchema();
schema.addColumn(new Column("boolean", TypeInfoFactory.BOOLEAN));
schema.addColumn(new Column("bigint", TypeInfoFactory.BIGINT));
schema.addPartitionColumn(new Column("date", TypeInfoFactory.DATE));
schema.addPartitionColumn(new Column("tinyint", TypeInfoFactory.TINYINT));
schema.addPartitionColumn(new Column("smallint", TypeInfoFactory.SMALLINT));
schema.addPartitionColumn(new Column("int", TypeInfoFactory.INT));
schema.addPartitionColumn(new Column("timestamp", TypeInfoFactory.TIMESTAMP));
schema.addPartitionColumn(new Column("char", TypeInfoFactory.getCharTypeInfo(10)));
schema.addPartitionColumn(new Column("varchar", TypeInfoFactory.getVarcharTypeInfo(10)));
schema.addPartitionColumn(new Column("string", TypeInfoFactory.STRING));
schema.addPartitionColumn(new Column("float", TypeInfoFactory.FLOAT));
schema.addPartitionColumn(new Column("double", TypeInfoFactory.DOUBLE));
schema.addPartitionColumn(new Column("decimalv2",
TypeInfoFactory.getDecimalTypeInfo(12, 4)));
schema.addPartitionColumn(new Column("decimal64",
TypeInfoFactory.getDecimalTypeInfo(10, 3)));
schema.addPartitionColumn(new Column("decimal18",
TypeInfoFactory.getDecimalTypeInfo(18, 5)));
schema.addPartitionColumn(new Column("timestamp4", TypeInfoFactory.TIMESTAMP));
return schema;
}

Expand Down

0 comments on commit dd9a1a2

Please sign in to comment.