Skip to content

Commit b2f3ef3

Browse files
committed
Improvement of ResultSet metadata
1 parent 5d545c0 commit b2f3ef3

File tree

30 files changed

+303
-87
lines changed

30 files changed

+303
-87
lines changed

client/trino-cli/src/test/java/io/trino/cli/TestAlignedTablePrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public void testAlignedPrintingWideCharacters()
277277

278278
static Column column(String name, String type)
279279
{
280-
return new Column(name, type, new ClientTypeSignature(type));
280+
return new Column("", "", "", name, name, type, new ClientTypeSignature(type));
281281
}
282282

283283
static List<?> row(Object... values)

client/trino-cli/src/test/java/io/trino/cli/TestAutoTablePrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testWidePrinting()
9898

9999
static Column column(String name, String type)
100100
{
101-
return new Column(name, type, new ClientTypeSignature(type));
101+
return new Column("", "", "", name, name, type, new ClientTypeSignature(type));
102102
}
103103

104104
static List<?> row(Object... values)

client/trino-cli/src/test/java/io/trino/cli/TestMarkdownTablePrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void testMarkdownPrintingWideCharacters()
163163

164164
static Column column(String name, String type)
165165
{
166-
return new Column(name, type, new ClientTypeSignature(type));
166+
return new Column("", "", "", name, name, type, new ClientTypeSignature(type));
167167
}
168168

169169
static List<?> row(Object... values)

client/trino-cli/src/test/java/io/trino/cli/TestQueryRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static String createResults(MockWebServer server)
123123
server.url("/query.html?20160128_214710_00012_rk68b").uri(),
124124
null,
125125
null,
126-
ImmutableList.of(new Column("_col0", BIGINT, new ClientTypeSignature(BIGINT))),
126+
ImmutableList.of(new Column("", "", "", "_col0", "_col0", BIGINT, new ClientTypeSignature(BIGINT))),
127127
TypedQueryData.of(ImmutableList.of(ImmutableList.of(123))),
128128
StatementStats.builder()
129129
.setState("FINISHED")

client/trino-client/src/main/java/io/trino/client/Column.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,63 @@
2424
@Immutable
2525
public class Column
2626
{
27+
private final String catalog;
28+
private final String schema;
29+
private final String table;
2730
private final String name;
31+
private final String label;
2832
private final String type;
2933
private final ClientTypeSignature typeSignature;
3034

3135
@JsonCreator
3236
public Column(
37+
@JsonProperty("catalog") String catalog,
38+
@JsonProperty("schema") String schema,
39+
@JsonProperty("table") String table,
3340
@JsonProperty("name") String name,
41+
@JsonProperty("label") String label,
3442
@JsonProperty("type") String type,
3543
@JsonProperty("typeSignature") ClientTypeSignature typeSignature)
3644
{
45+
this.catalog = requireNonNull(catalog, "catalog is null");
46+
this.schema = requireNonNull(schema, "schema is null");
47+
this.table = requireNonNull(table, "table is null");
3748
this.name = requireNonNull(name, "name is null");
49+
this.label = requireNonNull(label, "label is null");
3850
this.type = requireNonNull(type, "type is null");
3951
this.typeSignature = typeSignature;
4052
}
4153

54+
@JsonProperty
55+
public String getCatalog()
56+
{
57+
return catalog;
58+
}
59+
60+
@JsonProperty
61+
public String getSchema()
62+
{
63+
return schema;
64+
}
65+
66+
@JsonProperty
67+
public String getTable()
68+
{
69+
return table;
70+
}
71+
4272
@JsonProperty
4373
public String getName()
4474
{
4575
return name;
4676
}
4777

78+
@JsonProperty
79+
public String getLabel()
80+
{
81+
return label;
82+
}
83+
4884
@JsonProperty
4985
public String getType()
5086
{

client/trino-client/src/test/java/io/trino/client/TestClientRedirect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ private String newQueryResults(MockWebServer server)
153153
server.url("/query.html?" + queryId).uri(),
154154
null,
155155
null,
156-
Stream.of(new Column("id", INTEGER, new ClientTypeSignature("integer")),
157-
new Column("name", VARCHAR, new ClientTypeSignature("varchar")))
156+
Stream.of(new Column("", "", "", "id", "id", INTEGER, new ClientTypeSignature("integer")),
157+
new Column("", "", "", "name", "name", VARCHAR, new ClientTypeSignature("varchar")))
158158
.collect(toList()),
159159
TypedQueryData.of(IntStream.range(0, numRecords)
160160
.mapToObj(index -> Stream.of((Object) index, "a").collect(toList()))

client/trino-client/src/test/java/io/trino/client/TestQueryResults.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ public class TestQueryResults
2929
" \"id\" : \"20160128_214710_00012_rk68b\",\n" +
3030
" \"infoUri\" : \"http://localhost:54855/query.html?20160128_214710_00012_rk68b\",\n" +
3131
" \"columns\" : [ {\n" +
32+
" \"catalog\" : \"_cat0\",\n" +
33+
" \"schema\" : \"_sch0\",\n" +
34+
" \"table\" : \"_tab0\",\n" +
3235
" \"name\" : \"_col0\",\n" +
36+
" \"label\" : \"_lab0\",\n" +
3337
" \"type\" : \"bigint\",\n" +
3438
" \"typeSignature\" : {\n" +
3539
" \"rawType\" : \"varchar\",\n" +

client/trino-client/src/test/java/io/trino/client/TestResultRowsDecoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private static QueryResults fromQueryData(QueryData queryData)
265265
URI.create("https://localhost"),
266266
URI.create("https://localhost"),
267267
URI.create("https://localhost"),
268-
ImmutableList.of(new Column("id", "integer", new ClientTypeSignature("integer", ImmutableList.of()))),
268+
ImmutableList.of(new Column("", "", "", "id", "id", "integer", new ClientTypeSignature("integer", ImmutableList.of()))),
269269
queryData,
270270
StatementStats.builder()
271271
.setState("FINISHED")

client/trino-client/src/test/java/io/trino/client/TestRetry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ private String newQueryResults(String state)
154154
server.url("/query.html?" + queryId).uri(),
155155
null,
156156
state.equals("RUNNING") ? server.url(format("/v1/statement/%s/%s", queryId, "aa")).uri() : null,
157-
Stream.of(new Column("id", INTEGER, new ClientTypeSignature("integer")),
158-
new Column("name", VARCHAR, new ClientTypeSignature("varchar")))
157+
Stream.of(new Column("", "", "", "id", "id", INTEGER, new ClientTypeSignature("integer")),
158+
new Column("", "", "", "name", "name", VARCHAR, new ClientTypeSignature("varchar")))
159159
.collect(toList()),
160160
TypedQueryData.of(IntStream.range(0, numRecords)
161161
.mapToObj(index -> Stream.of((Object) index, "a").collect(toList()))

client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractTrinoResultSet.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,11 +1970,11 @@ private static List<ColumnInfo> getColumnInfo(List<Column> columns)
19701970
ImmutableList.Builder<ColumnInfo> list = ImmutableList.builderWithExpectedSize(columns.size());
19711971
for (Column column : columns) {
19721972
ColumnInfo.Builder builder = new ColumnInfo.Builder()
1973-
.setCatalogName("") // TODO
1974-
.setSchemaName("") // TODO
1975-
.setTableName("") // TODO
1976-
.setColumnLabel(column.getName())
1977-
.setColumnName(column.getName()) // TODO
1973+
.setCatalogName(column.getCatalog())
1974+
.setSchemaName(column.getSchema())
1975+
.setTableName(column.getTable())
1976+
.setColumnLabel(column.getLabel())
1977+
.setColumnName(column.getName())
19781978
.setColumnTypeSignature(column.getTypeSignature())
19791979
.setNullable(Nullable.UNKNOWN)
19801980
.setCurrency(false);

0 commit comments

Comments
 (0)