Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ec2fc0c
refactor using timestmap
xinyual Apr 14, 2025
7bd949c
refactor for timestmap
xinyual Apr 14, 2025
7132976
transfer basic functions
xinyual Apr 14, 2025
ae2e5c4
add functions
xinyual Apr 14, 2025
75ed483
Refactor math UDFs
yuancu Apr 14, 2025
47b484e
Refactor text UDFs
yuancu Apr 14, 2025
0b23131
Fix function name resolving when system using Turkic languages
yuancu Apr 16, 2025
b9fcc29
Refactor date part, date/time manipulation UDFs
yuancu Apr 16, 2025
b361103
Refactor current, name, format UDFs
yuancu Apr 16, 2025
921039b
Refactor convert tz, date/timestamp diff UDFs
yuancu Apr 16, 2025
a8083ed
Refactor date / time functions with non-date/time arguments
yuancu Apr 18, 2025
7974493
Merge xinyual/RefactorUDF to refactor-udf
yuancu Apr 18, 2025
2058a17
Refactor datetime, sec_to_time, time_to_sec, sysdate, timestampadd, t…
yuancu Apr 21, 2025
276f83f
Refactor week, nullif, ifnull, if UDFs
yuancu Apr 21, 2025
98feeb2
Remove BuiltinFunctionUtils and unnecessary UDFs
yuancu Apr 21, 2025
4333520
Patch: throw proper semantic errors for date_part-related udfs
yuancu Apr 21, 2025
827debe
Fix bugs in datetime UDFs
yuancu Apr 21, 2025
e5e423d
Refactor: move all udf to org.opensearch.sql.expression.function.udf
yuancu Apr 22, 2025
abcfe1c
use timestamp to replace post process
xinyual Apr 22, 2025
0a56887
Merge pull request #1 from xinyual/refactorDelete
yuancu Apr 22, 2025
12b918b
Add more ITs for last day & restore Prometheus settings
yuancu Apr 22, 2025
fd67cba
Fix euler with UDF instead of directly returning a literal to match i…
yuancu Apr 22, 2025
0c3fc7d
Reimplment last_day UDF with expr methods
yuancu Apr 22, 2025
31380ca
Ignore tests related to parameter validaton temporarily since it's in…
yuancu Apr 23, 2025
6ab248a
Merge origin/main to refactor-udf
yuancu Apr 23, 2025
c74ab7b
Deprecate timestamp string as data context for function properties
yuancu Apr 23, 2025
c05f64e
Refactor: unify datetime udf structures
yuancu Apr 23, 2025
c7daa9f
Apply spotless & fix zone id acquirement
yuancu Apr 23, 2025
cb09566
Fix unixtimestamp from double when locale uses non-arabic numbers
yuancu Apr 23, 2025
9f6e7ae
Box operands so that relection calls match signatures containing non-…
yuancu Apr 23, 2025
d461141
Use system default time zone when restoring function properties
yuancu Apr 23, 2025
42fb239
Refactor return types
yuancu Apr 24, 2025
ce26d80
Use builtin case and coalesce to implement if, ifnull, nullif UDFs
yuancu Apr 25, 2025
95cd64e
Merge remote-tracking branch 'origin/main' into refactor-udf
yuancu Apr 25, 2025
9004078
Replace replace UDF with builtin implementations & add docs for repla…
yuancu Apr 25, 2025
378f278
Correct locate function documents
yuancu Apr 27, 2025
c4f51f6
Separate adddate and date_add implementations for readability
yuancu Apr 27, 2025
ea6e786
Add class documentations for UDFs
yuancu Apr 27, 2025
adfc231
Create PPLReturnTypes class to store common return types that it not …
yuancu Apr 27, 2025
058eb7c
Remove udf operators with the same implementations but different names
yuancu Apr 28, 2025
3a49e15
Merge origin/main into refactor-udf
yuancu May 6, 2025
714c908
Refactor: Move type comparison earlier in Add/Sub Date function imple…
yuancu May 7, 2025
ac030e4
Refactor: update add/sub time's implementation with adaptExprMethodWi…
yuancu May 7, 2025
1f93871
Refactor: Move type comparison earlier in last day function implement…
yuancu May 7, 2025
0cca41a
Refactor: implement date function with adaptExprMethodToUDF
yuancu May 7, 2025
17d0f5e
Refactor: Move type comparison earlier in extract function implementa…
yuancu May 7, 2025
5377216
Refactor: Move type comparison earlier in format function implementation
yuancu May 7, 2025
131e5df
Refactor: Move type comparison earlier in timestampdiff function impl…
yuancu May 7, 2025
3e11e63
Refactor: Move type comparison earlier in weekday function implementa…
yuancu May 7, 2025
6a5e668
Refactor: split add and sub date to 2 static functions
yuancu May 7, 2025
9147dfe
Eliminate convertRelDataTypeToSqlTypeName API, replacing it with Expr…
yuancu May 8, 2025
cc152b5
Refactor: pass expr values to udf implementations instead of passing …
yuancu May 8, 2025
6b78b84
Refactor: unify types in udf to use expr types (deprecating SqlTypeName)
yuancu May 8, 2025
3ec719d
Refactor: change return types of UDF implementations to their actual …
yuancu May 8, 2025
1295c88
Add a test to unix_timestamp with microseconds
yuancu May 9, 2025
7bcc800
Minor: fix calcite datetime tests
yuancu May 9, 2025
856b83e
Replace sqrt udf with a call to calcite's power(x, 0.5)
yuancu May 9, 2025
9025c6a
Replace locate udf with SqlStdOperatorTable.POSITION
yuancu May 9, 2025
63e84ac
Fix sqrt logical plan test
yuancu May 9, 2025
5991c99
Fix expectedSparkSql in sqrt test
yuancu May 9, 2025
8262890
Merge origin/main into refactor-udf
yuancu May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
import static org.apache.calcite.sql.SqlKind.AS;
import static org.opensearch.sql.ast.expression.SpanUnit.NONE;
import static org.opensearch.sql.ast.expression.SpanUnit.UNKNOWN;
import static org.opensearch.sql.calcite.utils.BuiltinFunctionUtils.VARCHAR_FORCE_NULLABLE;
import static org.opensearch.sql.calcite.utils.UserDefinedFunctionUtils.TransferUserDefinedFunction;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.type.RelDataType;
Expand All @@ -25,7 +22,6 @@
import org.apache.calcite.rex.RexCall;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.sql.SqlIntervalQualifier;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.util.DateString;
Expand Down Expand Up @@ -60,15 +56,14 @@
import org.opensearch.sql.ast.expression.subquery.ScalarSubquery;
import org.opensearch.sql.ast.tree.UnresolvedPlan;
import org.opensearch.sql.calcite.type.ExprSqlType;
import org.opensearch.sql.calcite.udf.datetimeUDF.PostprocessDateToStringFunction;
import org.opensearch.sql.calcite.utils.BuiltinFunctionUtils;
import org.opensearch.sql.calcite.utils.OpenSearchTypeFactory;
import org.opensearch.sql.calcite.utils.PlanUtils;
import org.opensearch.sql.common.utils.StringUtils;
import org.opensearch.sql.data.type.ExprType;
import org.opensearch.sql.exception.CalciteUnsupportedException;
import org.opensearch.sql.exception.SemanticCheckException;
import org.opensearch.sql.expression.function.BuiltinFunctionName;
import org.opensearch.sql.expression.function.PPLBuiltinOperators;
import org.opensearch.sql.expression.function.PPLFuncImpTable;

@RequiredArgsConstructor
Expand Down Expand Up @@ -220,18 +215,8 @@ public RexNode visitCompare(Compare node, CalcitePlanContext context) {
private RexNode transferCompareForDateRelated(
RexNode candidate, CalcitePlanContext context, boolean whetherCompareByTime) {
if (whetherCompareByTime) {
SqlOperator postToStringNode =
TransferUserDefinedFunction(
PostprocessDateToStringFunction.class,
"PostprocessDateToString",
VARCHAR_FORCE_NULLABLE);
RexNode transferredStringNode =
context.rexBuilder.makeCall(
postToStringNode,
List.of(
candidate,
context.rexBuilder.makeLiteral(
context.functionProperties.getQueryStartClock().instant().toString())));
context.rexBuilder.makeCall(PPLBuiltinOperators.TIMESTAMP, candidate);
return transferredStringNode;
} else {
return candidate;
Expand Down Expand Up @@ -351,26 +336,14 @@ public RexNode visitLet(Let node, CalcitePlanContext context) {
@Override
public RexNode visitFunction(Function node, CalcitePlanContext context) {
List<RexNode> arguments =
node.getFuncArgs().stream().map(arg -> analyze(arg, context)).collect(Collectors.toList());
node.getFuncArgs().stream().map(arg -> analyze(arg, context)).toList();
RexNode resolvedNode =
PPLFuncImpTable.INSTANCE.resolveSafe(
context.rexBuilder, node.getFuncName(), arguments.toArray(new RexNode[0]));
if (resolvedNode != null) {
return resolvedNode;
}
// TODO: Remove below code after migrating all functions to PPLFuncImpTable,
// https://github.com/opensearch-project/sql/issues/3524
SqlOperator operator = BuiltinFunctionUtils.translate(node.getFuncName());
List<RexNode> translatedArguments =
BuiltinFunctionUtils.translateArgument(
node.getFuncName(),
arguments,
context,
context.functionProperties.getQueryStartClock().instant().toString());
RelDataType returnType =
BuiltinFunctionUtils.deriveReturnType(
node.getFuncName(), context.rexBuilder, operator, translatedArguments);
return context.rexBuilder.makeCall(returnType, operator, translatedArguments);
throw new IllegalArgumentException("Unsupported operator: " + node.getFuncName());
}

@Override
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading