[
https://issues.apache.org/jira/browse/DRILL-1416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14132262#comment-14132262
]
Chun Chang commented on DRILL-1416:
-----------------------------------
from Jinfeng:
select cast(convert_to(rl[1], 'JSON') as varchar(100)) from
dfs.`/Users/jni/work/incubator-drill/exec/java-exec/src/test/resources/jsoninput/input2.json`;
+------------+
| EXPR$0 |
+------------+
| [ 4, 6 ] |
| null |
| [ 4, 6 ] |
| [ 4, 6 ] |
+------------+
the 2nd row of convert_to contains "null" which is not a valid JSON object.
Originally, JSON writer probably will output it as [null]. Now the behavior is
changed. Drill's JSON reader currently does not support null yet, as far as I
know.
> conver_from() on JSON fails - regression
> ----------------------------------------
>
> Key: DRILL-1416
> URL: https://issues.apache.org/jira/browse/DRILL-1416
> Project: Apache Drill
> Issue Type: Bug
> Components: Functions - Drill
> Affects Versions: 0.6.0
> Reporter: Chun Chang
> Assignee: Jinfeng Ni
>
> The following query worked before, but fails with the latest master (#Fri Sep
> 12 14:08:02 PDT 2014
> git.commit.id.abbrev=9e16466)
> 0: jdbc:drill:schema=dfs> select convert_from(convert_to(rl[1], 'JSON'),
> 'JSON') from `input2.json`;
> Query failed: Failure while running fragment. Failure while parsing JSON.
> Found token of [VALUE_NULL] Drill currently only supports parsing json
> strings that contain either lists or maps. The root object cannot be a
> scalar.
> at [Source: java.io.StringReader@3d552116; line: 1, column: 9]
> [8752d761-4ed4-4314-b621-e9f061849a11]
> Error: exception while executing query: Failure while trying to get next
> result batch. (state=,code=0)
> The input2.json file looks like this:
> [root@qa-node120 ~]# hadoop fs -cat /user/root/mondrian/input2.json
> { "integer" : 2010,
> "float" : 17.4,
> "x": {
> "y": "kevin",
> "z": "paul"
> },
> "z": [
> {"orange" : "yellow" , "pink": "red"},
> {"pink" : "purple" }
> ],
> "l": [4,2],
> "rl": [ [2,1], [4,6] ]
> }
> { "integer" : -2002,
> "float" : -1.2
> }
> { "integer" : 2001,
> "float" : 1.2,
> "x": {
> "y": "bill",
> "z": "peter"
> },
> "z": [
> {"pink" : "lilac" }
> ],
> "l": [4,2],
> "rl": [ [2,1], [4,6] ]
> }
> { "integer" : 6005,
> "float" : 1.2,
> "x": {
> "y": "mike",
> "z": "mary"
> },
> "z": [
> {"orange" : "stucco" }
> ],
> "l": [4,2],
> "rl": [ [2,1], [4,6] ]
> }
> The convert_to appears working:
> 0: jdbc:drill:schema=dfs> select convert_to(rl[1], 'JSON') from
> `input2.json`;
> +------------+
> | EXPR$0 |
> +------------+
> | [B@3a8a8b88 |
> | [B@5dceabbe |
> | [B@2b6d770f |
> | [B@1fa3900f |
> +------------+
> 4 rows selected (0.116 seconds)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)