-
Notifications
You must be signed in to change notification settings - Fork 304
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
[#4867] feat(core): Add storage support for columns in Gravitino #5078
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,290 @@ | |||
-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we are going to release a new version then a corresponding schema SQL file is needed, am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the meaning, can you please explain more?
.withDefaultValue( | ||
columnEntity.defaultValue() == null | ||
|| columnEntity.defaultValue().equals(Column.DEFAULT_VALUE_NOT_SET) | ||
? null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the value of nullable is false
, can we set the default value as null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this DEFAULT_VALUE_NOT_SET
to represent null, I think it is aligned with ColumnDTO's current implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For column default value, we use DEFAULT_VALUE_NOT_SET
and Literals.NULL
to represent different default values:
- For
DEFAULT_VALUE_NOT_SET
, it means that the user has not set a default value. If the column isnullable=false
, then this default value will be entirely determined by the underlying catalog (for example, some engines set the default value ofcolumn int not null
to0
). - For
Literals.NULL
, if the columnnullable=true
, we can useLiterals.NULL
to explicitly specify the default value as null. if we useDEFAULT_VALUE_NOT_SET
, then this default value will be entirely determined by the underlying catalog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For column default value, we use
DEFAULT_VALUE_NOT_SET
andLiterals.NULL
to represent different default values:
- For
DEFAULT_VALUE_NOT_SET
, it means that the user has not set a default value. If the column isnullable=false
, then this default value will be entirely determined by the underlying catalog (for example, some engines set the default value ofcolumn int not null
to0
).- For
Literals.NULL
, if the columnnullable=true
, we can useLiterals.NULL
to explicitly specify the default value as null. if we useDEFAULT_VALUE_NOT_SET
, then this default value will be entirely determined by the underlying catalog
I see, let me update the code.
...org/apache/gravitino/storage/relational/mapper/provider/base/TableColumnBaseSQLProvider.java
Outdated
Show resolved
Hide resolved
mapper.insertTableMetaOnDuplicateKeyUpdate(po); | ||
} else { | ||
mapper.insertTableMeta(po); | ||
TableColumnMetaService.getInstance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good way to judge if there has been a change in the table so that we don't need to drop all columns and create them if no changes have been made to them such as table renaming, or altering table comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TableColumnMetaService.getInstance().isColumnUpdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to drop all columns and create them if no changes have been made to them such as table renaming, or altering table comments
If we don't want to update the columns, we have to fetch the old columns then do the comparison. The current overwrite
doesn't fetch the old data, so we have to fetch again, the overhead is the same.
List<ColumnPO> columnPOsToInsert = Lists.newArrayList(); | ||
for (ColumnEntity newColumn : newColumns.values()) { | ||
ColumnEntity oldColumn = oldColumns.get(newColumn.id()); | ||
if (oldColumn == null || !oldColumn.equals(newColumn)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if oldColumn == null
, it means the newColumn is a newly created one, so the op type should not be update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on how we define the UPDATE
or CREATE
, here in my implementation, I only set the type to CREATE
when table is created, UPDATE
for table update, no matter it is adding new column or updating the existing column.
Actually, no matter it is UPDATE
or CREATE
, what we only care if DELETE
, which is used to filter out deleted columns.
What changes were proposed in this pull request?
This PR aims to add storage support for columns in Gravitino.
Why are the changes needed?
With this, we can also support managing columns in Gravitno, like set tags, do column level privileges.
Fix: #4867
Does this PR introduce any user-facing change?
No.
How was this patch tested?
UTs added.