Skip to content

Conversation

@SourabhBadhya
Copy link
Contributor

@SourabhBadhya SourabhBadhya commented May 11, 2022

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

}
}

public static boolean isNonNativeTable(Map<String, String> tblProps) {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

@SourabhBadhya SourabhBadhya May 19, 2022

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);
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

please rename to createTableUseSuffix

Copy link
Contributor Author

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) {
Copy link
Member

@deniskuzZ deniskuzZ May 31, 2022

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());

Copy link
Contributor Author

@SourabhBadhya SourabhBadhya Jun 2, 2022

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())
Copy link
Member

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

Copy link
Contributor Author

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"

Copy link
Member

@deniskuzZ deniskuzZ left a comment

Choose a reason for hiding this comment

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

LGTM, pending tests

@deniskuzZ deniskuzZ merged commit 5b67170 into apache:master Jun 4, 2022
@SourabhBadhya SourabhBadhya deleted the HIVE-26217 branch June 7, 2022 15:27
DongWei-4 pushed a commit to DongWei-4/hive that referenced this pull request Oct 28, 2022
…viewed by Denys Kuzmenko, Peter Vary, Sai Hemanth Gantasala)

Closes apache#3281
dengzhhu653 pushed a commit to dengzhhu653/hive that referenced this pull request Dec 15, 2022
…viewed by Denys Kuzmenko, Peter Vary, Sai Hemanth Gantasala)

Closes apache#3281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants