Skip to content

Commit df74d7f

Browse files
committed
fix(commandapi): Fixed an issue where DescribeTableCommand had incorrect processing of extended type Column information
1 parent ad66483 commit df74d7f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

odps-sdk/odps-sdk-core/src/main/java/com/aliyun/odps/sqa/commandapi/DescribeTableCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class DescribeTableCommand implements Command {
7474
private static final Map<String, TypeInfo> extendedTableMap = new LinkedHashMap<>(tableMap);
7575

7676
static {
77+
extendedTableMap.replace("NativeColumns", TypeInfoFactory.getArrayTypeInfo(getExtendedStructTypeInfo()));
7778
extendedTableMap.put("ExtendedInfo", TypeInfoFactory
7879
.getMapTypeInfo(TypeInfoFactory.STRING, TypeInfoFactory.STRING));
7980
extendedTableMap.put("ExtendedInfoJson", TypeInfoFactory.STRING);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.aliyun.odps.data.converter;
2+
3+
import org.junit.Test;
4+
5+
import com.aliyun.odps.Odps;
6+
import com.aliyun.odps.commons.transport.OdpsTestUtils;
7+
import com.aliyun.odps.data.Record;
8+
import com.aliyun.odps.sqa.SQLExecutor;
9+
import com.aliyun.odps.sqa.SQLExecutorBuilder;
10+
11+
/**
12+
* @author dingxin ([email protected])
13+
*/
14+
public class FormatStructTest {
15+
16+
static OdpsRecordConverter odpsRecordConverter;
17+
18+
static {
19+
odpsRecordConverter = OdpsRecordConverter.builder()
20+
.setStrictMode(false)
21+
.enableParseNull()
22+
.build();
23+
}
24+
25+
@Test
26+
public void testListStruct() throws Exception {
27+
Odps odps = OdpsTestUtils.newDefaultOdps();
28+
SQLExecutor sqlExecutor = SQLExecutorBuilder.builder().odps(odps)
29+
.enableCommandApi(true)
30+
.useInstanceTunnel(true)
31+
.build();
32+
sqlExecutor.run("desc extended test;", null);
33+
34+
Record record = sqlExecutor.getResult().get(0);
35+
36+
String[] strings = odpsRecordConverter.formatRecord(record);
37+
for (String string : strings) {
38+
System.out.println(string);
39+
}
40+
}
41+
42+
43+
44+
}

0 commit comments

Comments
 (0)