Skip to content

Commit 0f75273

Browse files
committed
Add test for complex type
1 parent 837c3ba commit 0f75273

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

cmd/save/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ func saveTable(ctx context.Context, client *presto.Client, catalog, schema, tabl
127127
ts := &TableSummary{Catalog: catalog, Schema: schema, Name: table}
128128
if err := ts.QueryTableSummary(ctx, client); err != nil {
129129
logTableInfo(log.Error()).Err(err).Msg("failed to query table summary")
130-
return
131130
}
132131
filePath := filepath.Join(PrestoFlags.OutputPath,
133132
fmt.Sprintf("%s_%s_%s.json", catalog, schema, table))

cmd/save/table_summary.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,9 @@ func (s *TableSummary) QueryTableSummary(ctx context.Context, client *presto.Cli
135135
continue
136136
}
137137

138-
statsQueryBuilder := strings.Builder{}
139-
statsQueryBuilder.WriteString("SELECT ")
140-
statsQueryBuilder.WriteString(strings.Join(statistics, ", "))
141-
statsQueryBuilder.WriteString(" FROM " + fullyQualifiedTableName)
142-
log.Debug().Str("query", statsQueryBuilder.String()).Send()
143-
if err := presto.QueryAndUnmarshal(ctx, client, statsQueryBuilder.String(), stat); err != nil {
138+
query := fmt.Sprintf("SELECT %s FROM %s", strings.Join(statistics, ", "), fullyQualifiedTableName)
139+
log.Debug().Str("query", query).Send()
140+
if err := presto.QueryAndUnmarshal(ctx, client, query, stat); err != nil {
144141
return err
145142
}
146143
if stat.NullsFraction == nil {

cmd/save/test_complex.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
set session hive.collect_column_statistics_on_write=false;
2+
3+
-- map
4+
create table
5+
tmap (
6+
c1 map (
7+
varchar,
8+
row (
9+
"string_value" varchar,
10+
"int_value" bigint,
11+
"float_value" double,
12+
"double_value" double
13+
)
14+
),
15+
c2 int
16+
) WITH (format = 'PARQUET');
17+
18+
INSERT INTO tmap VALUES
19+
(map(
20+
array['A', 'B'],
21+
array[ROW('a', 3, 4.0, 5.0), ROW('b', 6, 7.0, 8.0)]
22+
), 1),
23+
(map(
24+
array['C', 'D'],
25+
array[ROW('a2', 3, 4.0, 5.0), ROW('b2', 6, 7.0, 8.0)]
26+
), 2),
27+
(map(
28+
array['F', 'D'],
29+
array[ROW(null, null, null, 5.0), ROW('b2', 6, 7.0, 8.0)]
30+
), null);
31+
32+
-- array
33+
create table tarray(c1 array(row("name" varchar, "comment" varchar, "hint" varchar, "score" bigint, "tags" array(varchar))));
34+
35+
INSERT INTO tarray VALUES
36+
(array[
37+
ROW('a', 'a2', 'a3', 3, array['a4', 'a5', 'a6']),
38+
ROW('b', 'b2', 'b3', 4, array['b4'])]
39+
),
40+
(array[
41+
ROW('aa', 'a2', 'a3', 3, array['aa4']),
42+
ROW('bb', 'b2', 'b3', 4, array['b4'])]
43+
);
44+
45+
-- row
46+
create table trow(c1 row("string_value" varchar, "int_value" bigint, "float_value" double, "double_value" double));
47+
48+
INSERT INTO trow VALUES (row(row('a', 3, 4.0, 5.0))), (row(row('aa', 5, 6.0, 7.0)));

0 commit comments

Comments
 (0)