Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1437f21
add json functions
xinyual Apr 17, 2025
54356af
add new functions
xinyual Apr 17, 2025
7959906
add json related function
xinyual Apr 17, 2025
aab67c2
add all functions
xinyual Apr 21, 2025
8bf3509
add json functions
xinyual Apr 21, 2025
df9ecbb
fix IT
xinyual Apr 22, 2025
5093024
fix error message
xinyual Apr 22, 2025
9c8247c
add json
xinyual Apr 23, 2025
0d985e8
try field
xinyual Apr 23, 2025
1b7d4ed
add json
xinyual Apr 23, 2025
7f19872
update to splunk for extract
xinyual May 13, 2025
84e74b9
align with splunk
xinyual May 14, 2025
89df431
fi original IT
xinyual May 14, 2025
1fd7fea
change array and json function
xinyual May 14, 2025
ea098e6
return string
xinyual May 15, 2025
64dae6e
merge from main
xinyual May 15, 2025
1de8156
apply spotless
xinyual May 15, 2025
3fc8f38
revert useless change
xinyual May 15, 2025
34a616f
apply spotless
xinyual May 15, 2025
1202b87
revert useless change
xinyual May 15, 2025
7690d78
revert useless change
xinyual May 15, 2025
eed5aa9
align with splunk
xinyual May 16, 2025
0e43eb9
remove useless change
xinyual May 16, 2025
d7c1a9a
remove useless change
xinyual May 16, 2025
330a989
remove useless change
xinyual May 16, 2025
ca49008
remove useless change
xinyual May 16, 2025
0a648bf
remove useless change
xinyual May 16, 2025
019b67a
change extract implementation
xinyual May 16, 2025
a2cf460
apply spotles
xinyual May 16, 2025
3662661
add more IT
xinyual May 19, 2025
50738d6
remove to json string
xinyual May 19, 2025
6621bf3
remove useless change
xinyual May 19, 2025
f444398
add UT
xinyual May 22, 2025
e5fc7a5
add some doc
xinyual May 22, 2025
af2ace5
add docs
xinyual May 23, 2025
e59d8fe
fix doc
xinyual May 28, 2025
d30be16
add json path
xinyual May 28, 2025
8cc986a
optimize doc
xinyual May 29, 2025
8833a3f
optimize doc
xinyual May 29, 2025
aba660f
optimize doc
xinyual May 29, 2025
a199066
optimize doc
xinyual May 29, 2025
5cf3d9d
optimize doc
xinyual May 29, 2025
06100e3
optimize doc
xinyual May 29, 2025
64177d8
optimize doc
xinyual May 29, 2025
e411c4a
Merge remote-tracking branch 'origin/main' into addJsonFunctions
xinyual Jun 4, 2025
19b47a3
add version and limitation to docs
xinyual Jun 5, 2025
425afc8
remove original implementation of V2
xinyual Jun 5, 2025
10b102a
revert useless change
xinyual Jun 5, 2025
0af8cc8
remove useless UTs
xinyual Jun 5, 2025
895f24c
Ignore useless IT
xinyual Jun 5, 2025
b578d4d
Merge remote-tracking branch 'origin/main' into addJsonFunctions
xinyual Jun 5, 2025
2a0bad8
Merge remote-tracking branch 'origin/main' into HEAD
xinyual Jun 6, 2025
b2ba7a8
update doc
xinyual Jun 6, 2025
13d1880
merge from main
xinyual Jun 6, 2025
dad3178
add type checker for json
xinyual Jun 6, 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
1 change: 0 additions & 1 deletion async-query-core/src/main/antlr/OpenSearchPPLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@ jsonFunctionName
| JSON_OBJECT
| JSON_ARRAY
| JSON_ARRAY_LENGTH
| TO_JSON_STRING
| JSON_EXTRACT
| JSON_KEYS
| JSON_VALID
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ allprojects {
}
configurations.all {
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.9.10"
resolutionStrategy.force "net.minidev:json-smart:${versions.json_smart}"
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10"
resolutionStrategy.force "net.bytebuddy:byte-buddy:1.14.19"
resolutionStrategy.force "org.apache.httpcomponents.client5:httpclient5:${versions.httpclient5}"
Expand Down
2 changes: 2 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ dependencies {
api 'org.apache.calcite:calcite-linq4j:1.38.0'
api project(':common')
implementation "com.github.seancfoley:ipaddress:5.4.2"
implementation "com.jayway.jsonpath:json-path:2.9.0"
implementation "com.googlecode.aviator:aviator:5.4.3"

annotationProcessor('org.immutables:value:2.8.8')
compileOnly('org.immutables:value-annotations:2.8.8')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ public enum BuiltinFunctionName {
LIKE(FunctionName.of("like")),
NOT_LIKE(FunctionName.of("not like")),

/** LAMBDA Functions * */
ARRAY_FORALL(FunctionName.of("forall")),
ARRAY_EXISTS(FunctionName.of("exists")),
ARRAY_FILTER(FunctionName.of("filter")),
ARRAY_TRANSFORM(FunctionName.of("transform")),
ARRAY_AGGREGATE(FunctionName.of("reduce")),

/** Aggregation Function. */
AVG(FunctionName.of("avg")),
SUM(FunctionName.of("sum")),
Expand Down Expand Up @@ -212,9 +219,21 @@ public enum BuiltinFunctionName {
TRIM(FunctionName.of("trim")),
UPPER(FunctionName.of("upper")),

/** Array Functions. */
ARRAY(FunctionName.of("array")),

/** Json Functions. */
JSON_VALID(FunctionName.of("json_valid")),
JSON(FunctionName.of("json")),
JSON_OBJECT(FunctionName.of("json_object")),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docs for new functions.

JSON_ARRAY(FunctionName.of("json_array")),
JSON_ARRAY_LENGTH(FunctionName.of("json_array_length")),
JSON_EXTRACT(FunctionName.of("json_extract")),
JSON_KEYS(FunctionName.of("json_keys")),
JSON_SET(FunctionName.of("json_set")),
JSON_DELETE(FunctionName.of("json_delete")),
JSON_APPEND(FunctionName.of("json_append")),
JSON_EXTEND(FunctionName.of("json_extend")),

/** GEOSPATIAL Functions. */
GEOIP(FunctionName.of("geoip")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.opensearch.sql.expression.datetime.DateTimeFunctions;
import org.opensearch.sql.expression.datetime.IntervalClause;
import org.opensearch.sql.expression.ip.IPFunctions;
import org.opensearch.sql.expression.json.JsonFunctions;
import org.opensearch.sql.expression.operator.arthmetic.ArithmeticFunctions;
import org.opensearch.sql.expression.operator.arthmetic.MathematicalFunctions;
import org.opensearch.sql.expression.operator.convert.TypeCastOperators;
Expand Down Expand Up @@ -84,7 +83,6 @@ public static synchronized BuiltinFunctionRepository getInstance() {
SystemFunctions.register(instance);
OpenSearchFunctions.register(instance);
IPFunctions.register(instance);
JsonFunctions.register(instance);
}
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
import org.opensearch.sql.calcite.utils.UserDefinedFunctionUtils;
import org.opensearch.sql.data.type.ExprCoreType;
import org.opensearch.sql.expression.datetime.DateTimeFunctions;
import org.opensearch.sql.expression.function.jsonUDF.JsonAppendFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonArrayLengthFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonDeleteFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonExtendFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonExtractFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonKeysFunctionImpl;
import org.opensearch.sql.expression.function.jsonUDF.JsonSetFunctionImpl;
import org.opensearch.sql.expression.function.udf.CryptographicFunction;
import org.opensearch.sql.expression.function.udf.GrokFunction;
import org.opensearch.sql.expression.function.udf.SpanFunction;
Expand Down Expand Up @@ -64,6 +72,18 @@
/** Defines functions and operators that are implemented only by PPL */
public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {

// Json Functions
public static final SqlOperator JSON = new JsonFunctionImpl().toUDF("JSON");
public static final SqlOperator JSON_ARRAY_LENGTH =
new JsonArrayLengthFunctionImpl().toUDF("JSON_ARRAY_LENGTH");
public static final SqlOperator JSON_EXTRACT =
new JsonExtractFunctionImpl().toUDF("JSON_EXTRACT");
public static final SqlOperator JSON_KEYS = new JsonKeysFunctionImpl().toUDF("JSON_KEYS");
public static final SqlOperator JSON_SET = new JsonSetFunctionImpl().toUDF("JSON_SET");
public static final SqlOperator JSON_DELETE = new JsonDeleteFunctionImpl().toUDF("JSON_DELETE");
public static final SqlOperator JSON_APPEND = new JsonAppendFunctionImpl().toUDF("JSON_APPEND");
public static final SqlOperator JSON_EXTEND = new JsonExtendFunctionImpl().toUDF("JSON_EXTEND");

// Math functions
public static final SqlOperator SPAN = new SpanFunction().toUDF("SPAN");
public static final SqlOperator E = new EulerFunction().toUDF("E");
Expand Down
Loading
Loading