-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-26217: Make CTAS use Direct Insert Semantics #3281
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
Conversation
| } | ||
| } | ||
|
|
||
| public static boolean isNonNativeTable(Map<String, String> tblProps) { |
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.
same function is already available: MetaStoreUtils.isNonNativeTable(), can't we use it?
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.
MetaStoreUtils.isNonNativeTable() uses Table object as argument and I needed a util method with Properties of table since Table object is created at a later stage and properties are available before table creation in CTAS.
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.
could we create in MetaStoreUtils method that accepts Map<String, String> tblProps and reuse it in the original one?
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.
Updated.
| if (!isExternal && useSuffix) { | ||
| long txnId = Optional.ofNullable(pCtx.getContext()) | ||
| .map(ctx -> ctx.getHiveTxnManager().getCurrentTxnId()).orElse(0L); | ||
| suffix = SOFT_DELETE_PATH_SUFFIX + String.format(DELTA_DIGITS, txnId); |
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.
shouldn't be populating suffix if txnId=0
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.
Updated.
| String protoName = null, suffix = ""; | ||
| boolean isExternal = false; | ||
|
|
||
| boolean useSuffix = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_ACID_CREATE_TABLE_USE_SUFFIX) |
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.
please rename to createTableUseSuffix
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.
Renamed to createTableOrMVUseSuffix. Updated.
| || HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED); | ||
|
|
||
| if (createMVUseSuffix) { | ||
| if (useSuffix) { |
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.
createTableUseSuffix &= AcidUtils.isTablePropertyTransactional(pCtx.getCreateViewDesc().getTblProps());
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.
Updated.
| isExternal = pCtx.getCreateTable().isExternal(); | ||
|
|
||
| if (!isExternal && useSuffix) { | ||
| long txnId = Optional.ofNullable(pCtx.getContext()) |
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.
could we extract this part into the helper method, it's repeating in multiple places
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.
Updated and added a new function called "getTableOrMVSuffix"
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.
LGTM, pending tests
…viewed by Denys Kuzmenko, Peter Vary, Sai Hemanth Gantasala) Closes apache#3281
…viewed by Denys Kuzmenko, Peter Vary, Sai Hemanth Gantasala) Closes apache#3281
What changes were proposed in this pull request?
CTAS on transactional tables currently does a copy from staging location to table location. This can be avoided by using Direct Insert semantics. Added support for suffixed table locations as well.
Why are the changes needed?
To improve performance of CTAS query.
Does this PR introduce any user-facing change?
No
How was this patch tested?
QTests