morrySnow commented on code in PR #23257:
URL: https://github.com/apache/doris/pull/23257#discussion_r1301111310
##########
fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4:
##########
@@ -612,6 +613,7 @@ nonReserved
| INTO
| IS
| ITEMS
+ | KEY
Review Comment:
key is a reserve keyword, should not put in nonReserved list
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -1101,6 +1101,17 @@ public UnboundFunction
visitExtract(DorisParser.ExtractContext ctx) {
});
}
+ @Override
+ public Expression visitEncryptKey(DorisParser.EncryptKeyContext ctx) {
+ Expression db = new StringLiteral("");
+ if (ctx.dbName != null) {
+ db = new StringLiteral(ctx.dbName.getText());
+ }
+ Expression keyName = new StringLiteral(ctx.keyName.getText());
+ return new UnboundFunction("encryptKeyRef", false,
+ ImmutableList.of(db, keyName));
Review Comment:
return `new EncryptKeyRef(....);` is ok
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -107,6 +113,23 @@ public Expression visitLiteral(Literal literal,
ExpressionRewriteContext context
return literal;
}
+ @Override
+ public Expression visitEncryptKeyRef(EncryptKeyRef encryptKeyRef,
ExpressionRewriteContext context) {
+ String dbName = encryptKeyRef.getDbName();
+ ConnectContext connectContext = ConnectContext.get();
+ if (Strings.isNullOrEmpty(dbName)) {
+ dbName = connectContext.getDatabase();
+ }
+ Preconditions.checkArgument(!"".equals(dbName), "DB " + dbName + "not
found");
Review Comment:
throw `AnalysisException` directly
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -107,6 +113,23 @@ public Expression visitLiteral(Literal literal,
ExpressionRewriteContext context
return literal;
}
+ @Override
+ public Expression visitEncryptKeyRef(EncryptKeyRef encryptKeyRef,
ExpressionRewriteContext context) {
+ String dbName = encryptKeyRef.getDbName();
+ ConnectContext connectContext = ConnectContext.get();
+ if (Strings.isNullOrEmpty(dbName)) {
+ dbName = connectContext.getDatabase();
+ }
+ Preconditions.checkArgument(!"".equals(dbName), "DB " + dbName + "not
found");
+ dbName = ClusterNamespace.getFullName(connectContext.getClusterName(),
dbName);
+ org.apache.doris.catalog.Database database =
+ Env.getCurrentEnv().getInternalCatalog().getDbNullable(dbName);
+ Preconditions.checkArgument(database != null, "DB " + dbName + "not
found");
Review Comment:
throw AnalysisException directly
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java:
##########
@@ -463,6 +464,7 @@ public class BuiltinScalarFunctions implements
FunctionHelper {
scalar(ElementExtract.class, "%element_extract%"),
scalar(ElementSlice.class, "%element_slice%"),
scalar(Elt.class, "elt"),
+ scalar(EncryptKeyRef.class, "encryptKeyRef"),
Review Comment:
should not put this function in function list
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -107,6 +113,23 @@ public Expression visitLiteral(Literal literal,
ExpressionRewriteContext context
return literal;
}
+ @Override
+ public Expression visitEncryptKeyRef(EncryptKeyRef encryptKeyRef,
ExpressionRewriteContext context) {
+ String dbName = encryptKeyRef.getDbName();
+ ConnectContext connectContext = ConnectContext.get();
+ if (Strings.isNullOrEmpty(dbName)) {
+ dbName = connectContext.getDatabase();
+ }
+ Preconditions.checkArgument(!"".equals(dbName), "DB " + dbName + "not
found");
+ dbName = ClusterNamespace.getFullName(connectContext.getClusterName(),
dbName);
+ org.apache.doris.catalog.Database database =
+ Env.getCurrentEnv().getInternalCatalog().getDbNullable(dbName);
+ Preconditions.checkArgument(database != null, "DB " + dbName + "not
found");
+ EncryptKey encryptKey =
database.getEncryptKey(encryptKeyRef.getEncryptKeyName());
+ Preconditions.checkArgument(encryptKey != null, "Can not found
encryptKey" + encryptKeyRef.getEncryptKeyName());
Review Comment:
throw AnalysisException directly
##########
fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4:
##########
@@ -373,6 +373,7 @@ primaryExpression
| identifier
#columnReference
| base=primaryExpression DOT fieldName=identifier
#dereference
| LEFT_PAREN expression RIGHT_PAREN
#parenthesizedExpression
+ | KEY (dbName=identifier DOT)? keyName=identifier
#encryptKey
Review Comment:
align #xxxx
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]