yinzhijian commented on code in PR #9433: URL: https://github.com/apache/incubator-doris/pull/9433#discussion_r867502807
########## fe/fe-core/src/main/java/org/apache/doris/load/Load.java: ########## @@ -1044,26 +1047,52 @@ private static void initColumns(Table tbl, List<ImportColumnDesc> columnExprs, if (!needInitSlotAndAnalyzeExprs) { return; } - + Set<String> exprArgsColumns = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); + for (ImportColumnDesc importColumnDesc : copiedColumnExprs) { + if (importColumnDesc.isColumn()) { + continue; + } + List<SlotRef> slots = Lists.newArrayList(); + importColumnDesc.getExpr().collect(SlotRef.class, slots); + for (SlotRef slot : slots) { + String slotColumnName = slot.getColumnName(); + exprArgsColumns.add(slotColumnName); + } + } + Set<String> excludedColumns = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); // init slot desc add expr map, also transform hadoop functions for (ImportColumnDesc importColumnDesc : copiedColumnExprs) { // make column name case match with real column name String columnName = importColumnDesc.getColumnName(); - String realColName = tbl.getColumn(columnName) == null ? columnName + Column tblColumn = tbl.getColumn(columnName); + String realColName = tblColumn == null ? columnName : tbl.getColumn(columnName).getName(); if (importColumnDesc.getExpr() != null) { Expr expr = transformHadoopFunctionExpr(tbl, realColName, importColumnDesc.getExpr()); exprsByName.put(realColName, expr); } else { SlotDescriptor slotDesc = analyzer.getDescTbl().addSlotDescriptor(srcTupleDesc); - slotDesc.setType(ScalarType.createType(PrimitiveType.VARCHAR)); + // only support parquet format now + if (exprArgsColumns.contains(columnName) || formatType != TFileFormatType.FORMAT_PARQUET + || !useVectorizedLoad) { + // columns in expr args should be parsed as varchar type + slotDesc.setType(ScalarType.createType(PrimitiveType.VARCHAR)); + slotDesc.setColumn(new Column(realColName, PrimitiveType.VARCHAR)); + excludedColumns.add(realColName); + // ISSUE A: src slot should be nullable even if the column is not nullable. + // because src slot is what we read from file, not represent to real column value. + // If column is not nullable, error will be thrown when filling the dest slot, + // which is not nullable. + slotDesc.setIsNullable(true); + } else { + // in vectorized load, + // columns from files like parquet files can be parsed as the type in table schema + slotDesc.setType(tblColumn.getType()); + slotDesc.setColumn(new Column(realColName, tblColumn.getType())); + // non-nullable column is allowed in vectorized load with parquet format + slotDesc.setIsNullable(tblColumn.isAllowNull()); Review Comment: This is for in future versions, where doris column is not nullable and parquet is nullable,we can filter out unwanted values before executing expressions -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org