What & why / 来龙去脉
GeaFlow's DSL already ships 27 string functions (LTrim, RTrim, Substr,
Concat, …), but three everyday ones are missing: TRIM (strip whitespace from
both ends), and LPAD / RPAD (pad a string to a given length). These come up
constantly in data cleaning, so adding them is an immediately useful first PR.
DSL 已经有 27 个字符串函数,但还缺三个数据清洗里天天用的:TRIM(去首尾空格)、
LPAD/RPAD(左右填充到指定长度)。补上它们,第一个 PR 就能让人立刻用上。
The task / 要做的事
Add three scalar functions that match standard SQL behavior:
trim(str) — strip leading/trailing whitespace
lpad(str, len, pad) / rpad(str, len, pad) — pad to a target length
Where to look / 改哪些文件
- Copy the shape of
geaflow-dsl/geaflow-dsl-plan/src/main/java/org/apache/geaflow/dsl/udf/table/string/LTrim.java.
In the same folder add Trim.java, LPad.java, RPad.java — extend UDF,
add the @Description annotation, implement eval(...), and mind the null case.
- Register three lines in
BuildInSqlFunctionTable.java:
.add(GeaFlowFunction.of(Trim.class)).
- Add
function_trim.sql (etc.) under query/ and matching .txt files under expect/.
Done when / 完成标准
What & why / 来龙去脉
GeaFlow's DSL already ships 27 string functions (
LTrim,RTrim,Substr,Concat, …), but three everyday ones are missing:TRIM(strip whitespace fromboth ends), and
LPAD/RPAD(pad a string to a given length). These come upconstantly in data cleaning, so adding them is an immediately useful first PR.
DSL 已经有 27 个字符串函数,但还缺三个数据清洗里天天用的:
TRIM(去首尾空格)、LPAD/RPAD(左右填充到指定长度)。补上它们,第一个 PR 就能让人立刻用上。The task / 要做的事
Add three scalar functions that match standard SQL behavior:
trim(str)— strip leading/trailing whitespacelpad(str, len, pad)/rpad(str, len, pad)— pad to a target lengthWhere to look / 改哪些文件
geaflow-dsl/geaflow-dsl-plan/src/main/java/org/apache/geaflow/dsl/udf/table/string/LTrim.java.In the same folder add
Trim.java,LPad.java,RPad.java— extendUDF,add the
@Descriptionannotation, implementeval(...), and mind the null case.BuildInSqlFunctionTable.java:.add(GeaFlowFunction.of(Trim.class)).function_trim.sql(etc.) underquery/and matching.txtfiles underexpect/.Done when / 完成标准
@Descriptionnullinput returnsnullrather than throwing.sqltests +.txtexpectations pass viamvn teston the right test class