HappenLee commented on code in PR #13694:
URL: https://github.com/apache/doris/pull/13694#discussion_r1005549013


##########
be/src/vec/functions/function_string.h:
##########
@@ -302,6 +302,211 @@ struct Substr2Impl {
     }
 };
 
+template <bool Reverse>
+class FunctionMaskPartial;
+class FunctionMask : public IFunction {
+public:
+    static constexpr auto name = "mask";
+    static constexpr auto DEFAULT_UPPER_MASK = 'X';
+    static constexpr auto DEFAULT_LOWER_MASK = 'x';
+    static constexpr auto DEFAULT_NUMBER_MASK = 'n';
+    String get_name() const override { return name; }
+    static FunctionPtr create() { return std::make_shared<FunctionMask>(); }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return make_nullable(std::make_shared<DataTypeString>());
+    }
+
+    size_t get_number_of_arguments() const override { return 0; }
+
+    bool is_variadic() const override { return true; }
+
+    bool use_default_implementation_for_nulls() const override { return true; }
+    bool use_default_implementation_for_constants() const override { return 
true; }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        DCHECK_GE(arguments.size(), 1);
+        DCHECK_LE(arguments.size(), 4);
+
+        auto null_map = ColumnUInt8::create(input_rows_count, 0);
+
+        char upper = DEFAULT_UPPER_MASK, lower = DEFAULT_LOWER_MASK, number = 
DEFAULT_NUMBER_MASK;
+
+        ColumnPtr source_column;
+        auto res = ColumnString::create();
+        source_column = block.get_by_position(arguments[0]).column;
+        if (source_column->is_nullable()) {
+            auto* nullable = assert_cast<const 
ColumnNullable*>(source_column.get());
+            VectorizedUtils::update_null_map(null_map->get_data(), 
nullable->get_null_map_data());
+            source_column = nullable->get_nested_column_ptr();
+        }
+

Review Comment:
   maybe return error the other column is not `const` 



##########
gensrc/script/doris_builtins_functions.py:
##########
@@ -2054,6 +2054,9 @@
     [['substr', 'substring'], 'VARCHAR', ['VARCHAR', 'INT', 'INT'],
         '_ZN5doris15StringFunctions9substringEPN'
         '9doris_udf15FunctionContextERKNS1_9StringValERKNS1_6IntValES9_', '', 
'', 'vec', 'ALWAYS_NULLABLE'],
+    [['mask'], 'STRING', ['STRING', '...'], '', '', '', 'vec', 'CUSTOM'],

Review Comment:
   seems the function is `default` not `custom`?



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

Reply via email to