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

Support Semi-structured variant data type #4348

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Mar 7, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Support Semi-structured variant data type

Changelog

  • New Feature

Related Issues

#3916

Test Plan

Unit Tests

Stateless Tests

@mergify
Copy link
Contributor

mergify bot commented Mar 7, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Mar 7, 2022
@vercel
Copy link

vercel bot commented Mar 7, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/databend/databend/92h8fFjQ7FjufYvb7JTnufDbbMPT
✅ Preview: https://databend-git-fork-b41sh-variant-databend.vercel.app

@@ -150,6 +151,9 @@ pub trait Column: Send + Sync {
pub trait IntoColumn {
fn into_column(self) -> ColumnRef;
fn into_nullable_column(self) -> ColumnRef;

fn into_column_with_field(self, f: &ArrowField) -> ColumnRef;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So into_column & into_nullable_column can be removed because they are covered by new methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

into_column & into_nullable_column need to be kept, because in some cases we don't have a field

let size = column.len();
let mut builder = ColumnBuilder::<JsonValue>::with_capacity(size);

with_match_physical_primitive_type!(from_type.data_type_id().to_physical_type(), |$T| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringColumn cast to variant column is not covered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String can't be automatically casted to Variants, it must be explicitly cast using the to_variant function

Some(data_type) => {
match data_type.data_type_id() {
// arrow type has no nullable type
Nullable => unimplemented!(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Err(ErrorCode::LogicaError) is better ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think unimplemented is ok, this is not a logical error, nullable is defined by ourselves, arrow doesn't have a corresponding type.
what is your opinion? @sundy-li

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimplemented!() will panic, please use the error instead.

Copy link
Member

@sundy-li sundy-li Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use ErrorCode::UnImplement instead. There are other places to be improved...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we can modify it in other issues, as the implementation of nullable is not related to varint

Copy link
Member

@zhang2014 zhang2014 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me 👍

@BohuTANG BohuTANG merged commit e0e704e into databendlabs:main Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants