[
https://issues.apache.org/jira/browse/SENTRY-2439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16669540#comment-16669540
]
Hao Zhu commented on SENTRY-2439:
---------------------------------
Hi Team,
We need to fix all below regex to support backtick.
$ grep REGEX
sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/util/SimpleSemanticAnalyzer.java
private static final String CREATE_TABLE_REGEX = "^(CREATE)\\s+" +
"(TEMPORARY\\s+)?"
private static final String DROP_DB_REGEX = "^DROP\\s+" +
"(DATABASE|SCHEMA)\\s+"
private static final String DROP_TABLE_REGEX = "^DROP\\s+" + "TABLE\\s+" +
"(IF\\s+EXISTS\\s+)?"
private static final String DROP_VIEW_REGEX = "^DROP\\s+" + "VIEW\\s+" +
"(IF\\s+EXISTS\\s+)?"
private static final String DESCRIBE_DB_REGEX = "^DESCRIBE\\s+" +
"(DATABASE|SCHEMA)\\s+"
private static final String DESCRIBE_TABLE_REGEX = "^DESCRIBE\\s+"
private static final String SHOW_INDEX_REGEX = "^SHOW\\s+" +
"(FORMATTED\\s+)?"
private static final String SHOW_TBLPROPERTIES_REGEX = "^SHOW\\s+" +
"TBLPROPERTIES\\s+"
private static final String ALTER_TABLE_REGEX = "^ALTER\\s+" + "TABLE\\s+" +
"([A-Za-z0-9._]+)";
private static final String ALTER_VIEW_REGEX = "^ALTER\\s+" + "VIEW\\s+" +
"([A-Za-z0-9._]+)";
private static final String MSCK_REGEX = "^MSCK\\s+" + "REPAIR\\s" +
"TABLE\\s"
private static final String ALTER_INDEX_REGEX = "^ALTER\\s+" + "INDEX\\s+"
private static final String CREATE_FUNCTION_REGEX = "^CREATE\\s+" +
"(TEMPORARY\\s+)?"
One possible fix is to add backtick support:
eg:
{color:#000000}String
{color}{color:#7e504f}DROP_TABLE_REGEX{color}{color:#000000} =
{color}"^DROP\\s+"{color:#000000} + {color}"TABLE\\s+"{color:#000000} +
{color}"(IF\\s+EXISTS\\s+)?"
{color:#000000} + {color}"`?([A-Za-z0-9._]+)`?"{color:#000000};{color}
> "is not match table meta grammar error" with sentry-1.7
> --------------------------------------------------------
>
> Key: SENTRY-2439
> URL: https://issues.apache.org/jira/browse/SENTRY-2439
> Project: Sentry
> Issue Type: Bug
> Components: Sentry
> Affects Versions: 1.7.0
> Reporter: Shishr Prakash
> Priority: Major
>
> [What happened]
> After enabling sentry I am getting below error with DDLs like DROP table .
> similar to sentry bug-1845.
> [1] https://issues.apache.org/jira/browse/SENTRY-1845
> ====Error ===
> 2 rows selected (0.171 seconds)
> 0: jdbc:hive2://maprtest03:10000> DROP TABLE project_dev_out_hive;
> Error: Error while compiling statement: FAILED: HiveAuthzPluginException
> class
> org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException:
> this command DROP TABLE project_dev_out_hive is not match table meta grammar
> (state=42000,code=40000)
> ======
> It is not the same issue, but a similar issue for DROP TABLE command. The
> Sentry regex pattern for DROP TABLE command does not seem to be supporting
> backtick.
> String DROP_TABLE_REGEX = "^DROP\s+" + "TABLE\s+" + "(IF\s+EXISTS\s+)?" +
> "([A-Za-z0-9._]+)";
> Looks like it is not fixed in the latest version as well (the same pattern is
> used in the master branch as well). Hive seems to be supporting this syntax.
> ## Steps to Reproduce
> Try dropping hive table with backticks as below
> DROP TABLE `project_dev_out_hive`;
> ### What you expected to happen
> Sentry should understand backticks and it should work for every command.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)