You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "gustavodemorais (via GitHub)" <gi...@apache.org> on 2025/01/20 11:54:16 UTC
[PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
gustavodemorais opened a new pull request, #26022:
URL: https://github.com/apache/flink/pull/26022
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
It is currently not possible to declare a SQL string that contains existing JSON as valid JSON for JSON_OBJECT. Something like JSON_OBJECT(KEY 'K' VALUE '\{"value": 42}') returns \{"K", "{"value": 42}"}, where the value is a string a not a json object.
This PR adds support for the JSON() function. It's the initial support for it, until this function returns the JSON datatype (what we still don't have in flink).
Example:
```
jsonObject(JsonOnNull.NULL, "nested", json('{"value": 42}'))
JSON_OBJECT(KEY 'K' VALUE JSON('{"value": 42}'))
// {"nested":{"value":42}}
```
## Brief change log
- *Add JSON BuiltInFunction definition*
- *Update JsonObjectCallGen to support JSON function logic*
- *Update expressions*
- *Add tests for json function*
## Verifying this change
This change added tests for multiple uses cases of the function. Also added tests to make sure the fucnction is only called within JSON_OBJECT.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: yes
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs, JavaDocs
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1923330610
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LogicalTypeRoot.java:
##########
@@ -139,6 +139,8 @@ public enum LogicalTypeRoot {
SYMBOL(LogicalTypeFamily.EXTENSION),
+ JSON(LogicalTypeFamily.CHARACTER_STRING),
Review Comment:
Oh, I had changed this by accident. Thanks for the hint
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1928591112
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -476,6 +485,11 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, nullableInput: Boolean)
call.getOperator.getReturnTypeInference == ReturnTypes.ARG0 =>
generateNullLiteral(resultType)
+ // We only support JSON function operands within JSON_OBJECT
+ case (operand: RexNode, _)
+ if isJsonObjectOrArrayOperand(call) && isJsonFunctionOperand(operand) =>
Review Comment:
Since we use `OrArrayOperand`? Do we support JSON_ARRAY?
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -476,6 +485,11 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, nullableInput: Boolean)
call.getOperator.getReturnTypeInference == ReturnTypes.ARG0 =>
generateNullLiteral(resultType)
+ // We only support JSON function operands within JSON_OBJECT
+ case (operand: RexNode, _)
Review Comment:
```suggestion
case (operand: RexNode, i)
```
also check that the index is even. otherwise JSON() function could be used for the key?
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -861,9 +862,13 @@ public static ApiExpression withoutColumns(Object head, Object... tail) {
* jsonObject(JsonOnNull.ABSENT, "K1", nullOf(DataTypes.STRING())) // "{}"
*
* // {"K1":{"K2":"V"}}
+ * jsonObject(JsonOnNull.NULL, "K1", json('{"K2":"V"}'))
Review Comment:
thanks for updating the JavaDocs of `json()`. Seems this line still needs an update.
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/JsonFunction.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.functions.scalar;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.TableRuntimeException;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.SpecializedFunction.SpecializedContext;
+
+import javax.annotation.Nullable;
+
+/** Implementation of {@link BuiltInFunctionDefinitions#JSON}. */
+@Internal
+public class JsonFunction extends BuiltInScalarFunction {
Review Comment:
Remove?
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -459,6 +460,14 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, nullableInput: Boolean)
override def visitCall(call: RexCall): GeneratedExpression = {
val resultType = FlinkTypeFactory.toLogicalType(call.getType)
+
+ // throw exception if json function is called outside JSON_OBJECT
+ if (isJsonFunctionOperand(call)) {
+ throw new ValidationException(
+ "The JSON function is currently only supported inside a JSON_OBJECT." +
Review Comment:
```suggestion
"The JSON() function is currently only supported inside a JSON_OBJECT() function." +
```
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
replace with `runtimeDeferred()`?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1922603675
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala:
##########
@@ -1098,4 +1098,16 @@ object CodeGenUtils {
GenerateUtils.generateFieldAccess(ctx, inputType, inputTerm, index)
}
}
+
+ def removeFunctionCall(code: String, functionPath: String, functionName: String): String = {
Review Comment:
Yep, had the same feeling. I'll do
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1923362765
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
Review Comment:
Hey, @davidradl. The SQL specification introduced a new JSON data type (ISO/IEC 9075-2:2023 introduced JSON type (T801)). There are some databases that already implemented it.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1932025118
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
runtimeProvided just works ✅ [commited](https://github.com/apache/flink/pull/26022/commits/804babd2bd84be26047d9603c39088d69f5bd5ad)
I had some other changes while trying to understand why runtimeDeferred didn't work that caused runtimeProvided not to work 😅
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1930899164
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -476,6 +485,11 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, nullableInput: Boolean)
call.getOperator.getReturnTypeInference == ReturnTypes.ARG0 =>
generateNullLiteral(resultType)
+ // We only support JSON function operands within JSON_OBJECT
+ case (operand: RexNode, _)
+ if isJsonObjectOrArrayOperand(call) && isJsonFunctionOperand(operand) =>
Review Comment:
I was reusing a method here and updated it to check specifically for json object. The intent of the PR is to add support only for json object. If we want to extend it, we can do it in other tickets/pr.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2612963787
Reviewed by Chi on 23/01/2025 Go back to the submitter with review comments.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2618168026
> why do we need a new function when we can already do this with json_object? Or am I missing something?
@davidradl In many cases, JSON is generated by external systems and already exists in columns or nested fields. Many times this JSON needs to be wrapped into another JSON, for this the JSON_OBJECT function needs to know that a parameter is pre-formatted JSON. For this the SQL standard introduces a JSON data type and JSON function:
see T802 [here](https://peter.eisentraut.org/blog/2023/04/04/sql-2023-is-finished-here-is-whats-new)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1931805263
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
~Me neither. Both make _some_ tests fail with ` Unknown call expression: JSON_OBJECT(NULL, 'K', JSON('{}'))` or similar. I wasn't/am not sure exactly what was missing by comparing with other funcs as I tried both deferred/provided. I think we'll need some code related to expression conversion. I'll take a look again to understand exactly what would be the difference~
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2602489391
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6cc53051fd0f10e901437de60d2118cd6ee71a63",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "6cc53051fd0f10e901437de60d2118cd6ee71a63",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6cc53051fd0f10e901437de60d2118cd6ee71a63 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1922292809
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
+ table: json(value)
+ description: |
+ Expects a JSON string and returns its values as-is without escaping it as a string.
Review Comment:
```suggestion
Expects a raw, pre-formatted JSON string and returns its values as-is without escaping it as a string.
```
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -861,9 +862,13 @@ public static ApiExpression withoutColumns(Object head, Object... tail) {
* jsonObject(JsonOnNull.ABSENT, "K1", nullOf(DataTypes.STRING())) // "{}"
*
* // {"K1":{"K2":"V"}}
+ * jsonObject(JsonOnNull.NULL, "K1", json('{"K2":"V"}'))
Review Comment:
```suggestion
* jsonObject(JsonOnNull.NULL, "K1", json("{'K2':'V'}"))
```
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/JsonGenerateUtils.scala:
##########
@@ -275,4 +306,5 @@ object JsonGenerateUtils {
ctx.addReusableMember(methodCode)
methodName
}
+
Review Comment:
nit: remove
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala:
##########
@@ -1098,4 +1098,16 @@ object CodeGenUtils {
GenerateUtils.generateFieldAccess(ctx, inputType, inputTerm, index)
}
}
+
+ def removeFunctionCall(code: String, functionPath: String, functionName: String): String = {
Review Comment:
This looks really hacky. Could we investigate a cleaner solution?
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/JsonGenerateUtils.scala:
##########
@@ -160,6 +165,17 @@ object JsonGenerateUtils {
|""".stripMargin
}
+ /** Returns a term which wraps the given input parameter as a raw value. */
+ private def createRawSingleStringInputTerm(valueExpr: GeneratedExpression): String = {
+ s"""
+ |
+ |$jsonUtils.getNodeFactory().rawValueNode(
+ | new ${typeTerm(classOf[RawValue])}(
+ | ${valueExpr.resultTerm} != null && ${valueExpr.resultTerm}.toString().equals("") ?
Review Comment:
nullability checking should be done with the `nullTerm` term
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -873,6 +878,35 @@ public static ApiExpression jsonObject(JsonOnNull onNull, Object... keyValues) {
return apiCall(JSON_OBJECT, arguments);
}
+ /**
+ * Expects a JSON string and returns its values as-is without escaping it as a string.
+ *
+ * <p>This function can currently only be used within the {@code JSON_OBJECT} function. It
Review Comment:
```suggestion
* <p>This function can currently only be used within the {@link #jsonObject(...)} function. It
```
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -861,9 +862,13 @@ public static ApiExpression withoutColumns(Object head, Object... tail) {
* jsonObject(JsonOnNull.ABSENT, "K1", nullOf(DataTypes.STRING())) // "{}"
*
* // {"K1":{"K2":"V"}}
+ * jsonObject(JsonOnNull.NULL, "K1", json('{"K2":"V"}'))
Review Comment:
or escaped? not sure how strict the user-defined JSON needs to be? maybe we should check and document this.
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LogicalTypeRoot.java:
##########
@@ -139,6 +139,8 @@ public enum LogicalTypeRoot {
SYMBOL(LogicalTypeFamily.EXTENSION),
+ JSON(LogicalTypeFamily.CHARACTER_STRING),
Review Comment:
This class can't and shouldn't be changed without a FLIP. Please revert this.
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -873,6 +878,35 @@ public static ApiExpression jsonObject(JsonOnNull onNull, Object... keyValues) {
return apiCall(JSON_OBJECT, arguments);
}
+ /**
+ * Expects a JSON string and returns its values as-is without escaping it as a string.
+ *
+ * <p>This function can currently only be used within the {@code JSON_OBJECT} function. It
+ * allows passing pre-formatted JSON strings that will be inserted directly into the resulting
+ * JSON structure rather than being escaped as a string value. This allows storing nested JSON
+ * structures in a JSON_OBJECT without processing them as strings. If the value is null or
+ * empty, the function returns {@code null}.
+ *
+ * <p>Examples:
+ *
+ * <pre>{@code
+ * // {"K":{"K2":42}}
+ * jsonObject(JsonOnNull.NULL, "K", json('{"K2": 42}'))
+ *
+ * // {"K":{"K2":{"K3":42}}}
+ * jsonObject(JsonOnNull.NULL, "K", json('{"K2":{"K3":42}}'))
+ *
+ * // {"K": null}
+ * jsonObject(JsonOnNull.NULL, "K", json(''))
+ *
+ * // Invalid - JSON function can only be used within JSON_OBJECT
+ * json("{\"value\": 42}")
+ * }</pre>
+ */
+ public static ApiExpression json(Object value) {
+ return apiCallAtLeastOneArgument(JSON, value);
Review Comment:
```suggestion
return apiCall(JSON, value);
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1928817518
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
My first take at it gave me the impression that we would have even more boilerplate code if we use runtimeDeferred - I can't just swap them. Would it be a bad practice using the runtime class here? Seems a bit simpler. What do you think?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1928799919
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -861,9 +862,13 @@ public static ApiExpression withoutColumns(Object head, Object... tail) {
* jsonObject(JsonOnNull.ABSENT, "K1", nullOf(DataTypes.STRING())) // "{}"
*
* // {"K1":{"K2":"V"}}
+ * jsonObject(JsonOnNull.NULL, "K1", json('{"K2":"V"}'))
Review Comment:
Ops, yes
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1928632545
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
Review Comment:
I understand there is a new json type - please could you point me to databases that have a SQL function called JSON().
I look at [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adjsn/generation.html#GUID-1084A518-A44A-4654-A796-C1DD4D8EC2AA) and see that they use json_object for the nested json_object.
also I see there is an example of a nested object using json_object in the [flink docs](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/table/functions/systemfunctions/):
```
JSON_OBJECT(
KEY 'K1'
VALUE JSON_OBJECT(
KEY 'K2'
VALUE 'V'
)
)
```
why do we need a new function when we can already do this with json_object? Or am I missing something?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2604330603
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2620225170
@twalthr thanks for your reply. I found this a bit misleading - is that all the examples could be coded with a nested json_object using a key. It would be good to document when this would be useful. I assume maybe a dynamic table with a JDBC connector and column defined as a String could use this function to convert the string to json - prior to us having the json type.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2624957804
The goal of the function is, for complex/nested json objects, to make the user's life easier if he doesn't want to rebuild every level of their json with our json primitives. That said, the best real-world example would be using a really long/complex example, but since this is not practical for documentation, we give short examples so that users can understand how the function works.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys merged PR #26022:
URL: https://github.com/apache/flink/pull/26022
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1936838615
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -691,6 +693,106 @@ private static List<TestSetSpec> jsonStringSpec() {
STRING().notNull()));
}
+ // Test with alias?? using str$1
Review Comment:
remove?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1925151673
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java:
##########
@@ -861,9 +862,13 @@ public static ApiExpression withoutColumns(Object head, Object... tail) {
* jsonObject(JsonOnNull.ABSENT, "K1", nullOf(DataTypes.STRING())) // "{}"
*
* // {"K1":{"K2":"V"}}
+ * jsonObject(JsonOnNull.NULL, "K1", json('{"K2":"V"}'))
Review Comment:
The string doesn't have to be escaped, I've updated the javadoc for the java expression and added one example using string literals that show that there's no need to escape it
```
* // {"K":{"K2":{"K3":42}}}
* jsonObject(
* JsonOnNull.NULL,
* "K",
* json("""
* {
* "K2": {
* "K3": 42
* }
* }
* """))
```
We escape in the java code since java also uses `"` to express strings. If using single quotes in python or string literals in java, there's no need to escape. If they're escaped, they are also processed properly as well and result in the same json object.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2607001419
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1937133396
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -691,6 +693,106 @@ private static List<TestSetSpec> jsonStringSpec() {
STRING().notNull()));
}
+ // Test with alias?? using str$1
Review Comment:
Uh, thanks. Deleted.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2624676637
Thanks for your feedback @davidrdl. I'm sure @gustavodemorais can maybe make it clearer that this function is for handling pre-formatted JSON before introducing the JSON type.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1931694563
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
Did you also try runtimeProvided? I don't understand why we need to provide a runtime class that will never be used or called?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1930922052
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/JsonFunction.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.functions.scalar;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.TableRuntimeException;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.SpecializedFunction.SpecializedContext;
+
+import javax.annotation.Nullable;
+
+/** Implementation of {@link BuiltInFunctionDefinitions#JSON}. */
+@Internal
+public class JsonFunction extends BuiltInScalarFunction {
Review Comment:
https://github.com/apache/flink/pull/26022#discussion_r1928817518
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1923362765
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
Review Comment:
Hey, @davidradl. The SQL specification introduced a new JSON data type (ISO/IEC 9075-2:2023 introduced JSON type (T801)). There are some databases that already implemented it and this is the first simple initial support for a specific use case.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2627064087
Thanks for the reviews, @twalthr
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais closed pull request #26022: [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT
URL: https://github.com/apache/flink/pull/26022
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1928817518
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
My first take at it gave me the impression that we would have even more boilerplate code if we go with runtimeDeferred - I can't just swap them. Would it be a bad practice using the runtime class here?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1931805263
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -2819,6 +2819,15 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
.runtimeDeferred()
.build();
+ public static final BuiltInFunctionDefinition JSON =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("JSON")
+ .kind(SCALAR)
+ .inputTypeStrategy(sequence(logical(LogicalTypeFamily.CHARACTER_STRING)))
+ .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
+ .runtimeClass("org.apache.flink.table.runtime.functions.scalar.JsonFunction")
Review Comment:
Me neither. Both make _some_ tests fail with ` Unknown call expression: JSON_OBJECT(NULL, 'K', JSON('{}'))` or similar. I wasn't/am not sure exactly what was missing by comparing with other funcs as I tried both deferred/provided. I think we'll need some code related to expression conversion. I'll take a look again to understand exactly what would be the difference
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1922491313
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
Review Comment:
I do not see a function called JSON in the other SQL implementations . I do not think we should be adding a newly named function.
I see function JSON_VALUE - can we not use this instead?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1922491313
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
Review Comment:
I do not see a function called JSON in the other SQL implementations . I do not think we should be adding a newly name function.
I see function JSON_VALUE - can we not use this instead?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1923333681
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala:
##########
@@ -1098,4 +1098,16 @@ object CodeGenUtils {
GenerateUtils.generateFieldAccess(ctx, inputType, inputTerm, index)
}
}
+
+ def removeFunctionCall(code: String, functionPath: String, functionName: String): String = {
Review Comment:
Alright, made a change and could simpifly the logic a lot. I think something like this feels cleaner: https://github.com/apache/flink/pull/26022/commits/812efe7340bde65cb6ac3ad63e52e8cea6198ce2#diff-2a1762af3f6bd3f984cdf27261f217384278f302437c632f32f35a60ffa1e624R32
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26022:
URL: https://github.com/apache/flink/pull/26022#discussion_r1928632545
##########
docs/data/sql_functions.yml:
##########
@@ -1069,6 +1072,30 @@ json:
)
)
```
+ - sql: JSON(value)
Review Comment:
I understand there is a new json type - please could you point me to databases that have a SQL function called JSON().
I look at [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adjsn/generation.html#GUID-1084A518-A44A-4654-A796-C1DD4D8EC2AA) and see that they use json_object for the nested json_object.
also I see there is an example of a nested object using json_object in the [flink docs](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/table/functions/systemfunctions/):
```
JSON_OBJECT(
KEY 'K1'
VALUE JSON_OBJECT(
KEY 'K2'
VALUE 'V'
)
)
```
why do we need a new function when we can already do this with json_object?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37175][table] Support JSON built-in function for JSON_OBJECT [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on PR #26022:
URL: https://github.com/apache/flink/pull/26022#issuecomment-2606982236
Made the changes as we discussed @twalthr. One additional thing I've changed is that we not only parse the json, but convert the json back to string before storing it. I think that makes sense, so we optimize the storage space by getting rid of unnecessary withe spaces/line breaks and so on before returning the value.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org