Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support json logical type in parquet files() (backport #49385) #49423

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions be/src/exec/parquet_schema_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ static Status get_parquet_type_from_primitive(const ::parquet::schema::NodePtr&
auto decimal_logical_type = std::dynamic_pointer_cast<const parquet::DecimalLogicalType>(logical_type);
*type_desc = TypeDescriptor::create_decimalv3_type(TYPE_DECIMAL128, decimal_logical_type->precision(),
decimal_logical_type->scale());
} else if (logical_type->is_JSON()) {
*type_desc = TypeDescriptor::create_json_type();
} else {
*type_desc = TypeDescriptor::create_varbinary_type(TypeDescriptor::MAX_VARCHAR_LENGTH);
}
Expand Down
42 changes: 42 additions & 0 deletions test/sql/test_files/R/json_parquet
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- name: test_json_parquet

create database db_${uuid0};
use db_${uuid0};

shell: ossutil64 mkdir oss://${oss_bucket}/test_files/parquet_format/${uuid0} >/dev/null || echo "exit 0" >/dev/null

shell: ossutil64 cp --force ./sql/test_files/parquet_format/json.parquet oss://${oss_bucket}/test_files/parquet_format/${uuid0}/ | grep -Pv "(average|elapsed)"
-- result:
0

Succeed: Total num: 1, size: 911. OK num: 1(upload 1 files).
-- !result

select * from files('path' = 'oss://${oss_bucket}/test_files/parquet_format/${uuid0}/*', 'format' = 'parquet');
-- result:
1 ["a", "b"]
2 ["c", "d"]
-- !result

create table t1 as select * from files('path' = 'oss://${oss_bucket}/test_files/parquet_format/${uuid0}/*', 'format' = 'parquet');

desc t1;
-- result:
id bigint YES true None
json_data json YES false None
-- !result

create table t2 (id bigint, array_col array<varchar(100)>);

insert into t2 select * from files('path' = 'oss://${oss_bucket}/test_files/parquet_format/${uuid0}/*', 'format' = 'parquet');
-- result:
-- !result

select * from t2;
-- result:
1 ["a","b"]
2 ["c","d"]
-- !result


shell: ossutil64 rm -rf oss://${oss_bucket}/test_files/parquet_format/${uuid0}/ > /dev/null
18 changes: 18 additions & 0 deletions test/sql/test_files/T/json_parquet
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- name: test_json_parquet

create database db_${uuid0};
use db_${uuid0};

shell: ossutil64 mkdir oss://${oss_bucket}/test_files/parquet_format/${uuid0} >/dev/null || echo "exit 0" >/dev/null
shell: ossutil64 cp --force ./sql/test_files/parquet_format/json.parquet oss://${oss_bucket}/test_files/parquet_format/${uuid0}/ | grep -Pv "(average|elapsed)"

select * from files('path' = 'oss://${oss_bucket}/test_files/parquet_format/${uuid0}/*', 'format' = 'parquet');

create table t1 as select * from files('path' = 'oss://${oss_bucket}/test_files/parquet_format/${uuid0}/*', 'format' = 'parquet');
desc t1;

create table t2 (id bigint, array_col array<varchar(100)>);
insert into t2 select * from files('path' = 'oss://${oss_bucket}/test_files/parquet_format/${uuid0}/*', 'format' = 'parquet');
select * from t2;

shell: ossutil64 rm -rf oss://${oss_bucket}/test_files/parquet_format/${uuid0}/ > /dev/null
Binary file added test/sql/test_files/parquet_format/json.parquet
Binary file not shown.
Loading