morrySnow commented on code in PR #68853:
URL: https://github.com/apache/doris/pull/68853#discussion_r4278801862


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java:
##########
@@ -191,7 +192,53 @@ public TypeCheckResult checkInputDataTypes() {
                 return commonCheckResult;
             }
         }
-        return checkInputDataTypesInternal();
+        TypeCheckResult result = checkInputDataTypesInternal();
+        if (result.success()) {
+            checkFileExpression(this);
+        }
+        return result;
+    }
+
+    /** Reject FILE values in SQL keys that require comparison, ordering, or 
hashing. */
+    public static void checkFileKey(Expression value, String operation) {

Review Comment:
   不要加到Expression类,放到ExpressionUtils里面



##########
fe/fe-catalog/src/main/java/org/apache/doris/analysis/FileLiteral.java:
##########
@@ -0,0 +1,100 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.catalog.StructField;
+import org.apache.doris.catalog.Type;
+
+import com.google.common.base.Preconditions;
+import com.google.gson.JsonNull;
+import com.google.gson.JsonObject;
+
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+import java.util.Objects;
+
+/** FILE constant wire carrier, independent of STRUCT. */
+public final class FileLiteral extends LiteralExpr {

Review Comment:
   为什么能搞出一个file literal?这是怎么能创造出来的?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ElementAt.java:
##########
@@ -127,23 +133,58 @@ public List<FunctionSignature> getSignatures() {
         if (arg0Type instanceof NullType) {
             return ImmutableList.of(
                     
FunctionSignature.ret(NullType.INSTANCE).args(NullType.INSTANCE, 
child(1).getDataType()));
-        }
-        if (arg0Type instanceof StructType) {
+        } else if (arg0Type instanceof StructType) {
             return 
ImmutableList.of(FunctionSignature.ret(structFieldType((StructType) arg0Type))
                     .args(arg0Type, child(1).getDataType()));
-        }
-        if (arg0Type instanceof VariantType) {
+        } else if (arg0Type instanceof VariantType) {
             DataType selectorType = child(1).getDataType();
             if (selectorType.isIntegralType() || selectorType.isBooleanType()) 
{
                 return ImmutableList.of(VARIANT_INDEX_SIGNATURE);
             }
             if (selectorType.isStringLikeType()) {
                 return ImmutableList.of(VARIANT_KEY_SIGNATURE);
             }
+        } else if (arg0Type.isFileType()) {
+            return 
ImmutableList.of(FunctionSignature.ret(fileField().getDataType())
+                    .args(arg0Type, child(1).getDataType()));

Review Comment:
   如果file类型也支持elementAt ,之前实现的 meta path 优化会有问题嘛?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########


Review Comment:
   这里也比较奇怪,按说如果不实现fe的cast,会自动返回原有表达式,不应当增加这些代码



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:
##########
@@ -729,6 +732,19 @@ public Expr visitSearchExpression(SearchExpression 
searchExpression,
         return searchPredicate;
     }
 
+    @Override
+    public Expr visitToFile(ToFile toFile, PlanTranslatorContext context) {
+        // Translation runs for the current EXECUTE. Never retain credentials 
on
+        // the Nereids expression, which can be reused by a prepared statement.
+        StatementContext statement = context.getStatementContext();
+        ConnectContext connection = statement.getConnectContext();
+        if (connection != null && connection.getStatementContext() != null) {
+            statement = connection.getStatementContext();
+        }
+        statement.registerUsedS3ResourceName(toFile.getResourceName());

Review Comment:
   这里对statementContext 用法比较奇怪。不要这样滥用context,后面需要重构



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnToThrift.java:
##########
@@ -177,7 +179,7 @@ public static void toChildrenThrift(Column column, TColumn 
tColumn) {
             tColumn.setChildrenColumn(new ArrayList<>());
             setChildrenTColumn(k, tColumn);
             setChildrenTColumn(v, tColumn);
-        } else if (column.getType().isStructType()) {
+        } else if (column.getType().isStructType() || 
column.getType().isFileType()) {

Review Comment:
   file type 的 children 是什么概念?



##########
fe/fe-core/src/main/java/org/apache/doris/qe/runtime/ThriftPlansBuilder.java:
##########
@@ -240,6 +242,26 @@ static Map<String, TAIResource> 
collectAiResources(ConnectContext connectContext
         return aiResourceMap;
     }
 
+    public static TS3Resource resolveS3Resource(ConnectContext context, String 
resourceName) {
+        StatementContext statement = context.getStatementContext();

Review Comment:
   statementContext原本的设计,并不希望在translator阶段还要提供功能,他应当严格限制到nereids内部



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java:
##########
@@ -557,6 +563,11 @@ public static List<Literal> getResultExpression(DataType 
type, PValues resultCon
                 Literal literal = new 
StringLiteral(resultContent.getStringValue(i));
                 res.add(literal);
             }
+        } else if (type.isVarBinaryType()) {
+            for (int row = 0; row < resultContent.getBytesValueCount(); row++) 
{

Review Comment:
   file 类型我理解不会参与delete,所以没有必要修改be常量折叠



-- 
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]

Reply via email to