[Coral-hive] Enable parsing spark created views without quoted keywords #503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
[Coral-hive] Enable parsing spark created views without quoted keywords
Description
There are a subset of reserved words like
timestamp
which are keywords in hive but not in spark. When views are created using spark engine and these reserved words are used as column name alias, the expanded view text does not have them backquoted. This results in translation errors likeThis patch attempts to fix this error by checking the tableproperties of the view to get hints on if the view is created using spark and sets
hive.support.sql11.reserved.keywords
appropriately so that translation of these views will succeed.Note that this patch intentionally uses the config string
hive.support.sql11.reserved.keywords
instead of the variableHiveConf.ConfVars.HIVE_SUPPORT_SQL11_RESERVED_KEYWORDS
. This is because theHiveParser.g
here is copied from Hive1.2.4
and assumes the presence of this conf but this conf has been removed in later releases triggeringjava.lang.NoSuchFieldError: HIVE_SUPPORT_SQL11_RESERVED_KEYWORDS
whenhive-common
from latest hive versions is found in the classpath during translation.Testing Done
Added unit tests and validates that the unit test fails without fix and passes with fix.
Validates that all the existing unit test passes.
Validated a custom build of this coral fix in spark-shell against a view with keyword
timestamp
and was able to get successful translation.Tested on current production views and did not find any regression.