[
https://issues.apache.org/jira/browse/CALCITE-4989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17497442#comment-17497442
]
Gavin Ray commented on CALCITE-4989:
------------------------------------
I was mistaken.
Spending some time tediously stepping through call stacks last night and this
morning, think I genuinely may see what's going on now.
The generated code is below:
{code:java}
public org.apache.calcite.linq4j.Enumerable bind(final
org.apache.calcite.DataContext root) {
final org.apache.calcite.linq4j.Enumerable _inputEnumerable =
org.apache.calcite.linq4j.Linq4j.asEnumerable(new Integer[] {
0});
return new org.apache.calcite.linq4j.AbstractEnumerable(){
public org.apache.calcite.linq4j.Enumerator enumerator() {
return new org.apache.calcite.linq4j.Enumerator(){
public final org.apache.calcite.linq4j.Enumerator inputEnumerator =
_inputEnumerable.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
return inputEnumerator.moveNext();
}
public void close() {
inputEnumerator.close();
}
public Object current() {
return
org.apache.calcite.runtime.JsonFunctions.jsonObject(org.apache.calcite.sql.SqlJsonConstructorNullClause.NULL_ON_NULL,
new Object[] {
"level1",
org.apache.calcite.runtime.JsonFunctions.jsonObject(org.apache.calcite.sql.SqlJsonConstructorNullClause.NULL_ON_NULL,
new Object[] {
"level2",
org.apache.calcite.runtime.JsonFunctions.jsonObject(org.apache.calcite.sql.SqlJsonConstructorNullClause.NULL_ON_NULL,
new Object[] {
{code}
So it looks like the
{noformat}
org.apache.calcite.runtime.JsonFunctions.jsonObject
{noformat}
Method may be incorrectly escaping it?
> Nested JSON_OBJECT creation does not produce proper json
> --------------------------------------------------------
>
> Key: CALCITE-4989
> URL: https://issues.apache.org/jira/browse/CALCITE-4989
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.29.0
> Reporter: Mans Singh
> Priority: Critical
> Labels: json_object
>
> I am trying to create a nested json object using JSON_OBJECT and am getting a
> json with escaped quotes.
>
> I have the following query in sql line :
>
> {code:java}
> select JSON_OBJECT(
> KEY 'level1'
> VALUE(
> JSON_OBJECT(
> KEY 'level2'
> VALUE(
> JSON_OBJECT(
> KEY 'level3'
> VALUE 'val3')
> )
> )
> )
> )
> from (values ('{"a":{"b":2}}')) t(v);
>
> {code}
> And it produces the result:
>
> {noformat}
> -------------------------------------------------------------
> EXPR$0
> -------------------------------------------------------------
> {"level1":" {\"level2\":\"{\\\"level3\\\":\\\"val3\\\"}\"}"}
> -------------------------------------------------------------
> {noformat}
>
> I was expecting the result as follows (without quote escapes):
>
> {noformat}
> {"level1":{"level2":{"level3":"val3"}}}
>
> {noformat}
> Also, see examples created by Stamatis
> -
> [https://github.com/zabetak/calcite/commit/988c13ce1ff551d6e4046a3c027ff298f79971f8]
--
This message was sent by Atlassian Jira
(v8.20.1#820001)