namhnguyen / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

ADM backslash issue #754

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The ADM data parser fails to parse a string containing an escape backslash.

Reproduction:
==============

drop dataverse kereno if exists;
create dataverse kereno;
use dataverse kereno;

create type page_info_type as open {}

create type page_views_type as closed {
        id: int32, 
        user: string?,
}

create dataset page_views(page_views_type)
primary key id;

load dataset page_views using localfs
(("path"="127.0.0.1:///home/kereno/Desktop/page_views_test.adm"),("format"="adm"
));

Error returned:
================
SyntaxError:Encountered " "}" "} "" at line 10, column 1.
Was expecting one of:
    <STRING_LITERAL> ...
    <IDENTIFIER> ...

==> }

Original issue reported on code.google.com by ker...@gmail.com on 4 Apr 2014 at 9:00

Attachments:

GoogleCodeExporter commented 9 years ago
An extension of this issue is issue 752.

Original comment by ker...@gmail.com on 4 Apr 2014 at 9:14

GoogleCodeExporter commented 9 years ago
The error message is due to an extra ',' at the end of the type declaration. 
The correct query is

drop dataverse kereno if exists;
create dataverse kereno;
use dataverse kereno;

create type page_info_type as open {}

create type page_views_type as closed {
        id: int32, 
        user: string?
}

create dataset page_views(page_views_type)
primary key id;

load dataset page_views using localfs
(("path"="127.0.0.1:///home/.../page_views_test.adm"),("format"="adm"));

The error produced by this query is:

Node 127.0.0.1 not live [HyracksException]

Original comment by westm...@gmail.com on 4 Apr 2014 at 9:51

GoogleCodeExporter commented 9 years ago
The behavior is a doubling of the backslashes: 
ADM input: {"id":1, "user":"keren\\"}
Web UI output: { "id": 1, "user": "keren\\\\" } //<== see the double backslashes

Original comment by ker...@gmail.com on 4 Apr 2014 at 10:01

GoogleCodeExporter commented 9 years ago
After modifying the query one more time (use "nc1" instead of "127.0.0.1", add 
the query) to 

drop dataverse kereno if exists;
create dataverse kereno;
use dataverse kereno;

create type page_views_type as closed {
        id: int32, 
        user: string?
}

create dataset page_views(page_views_type)
primary key id;

load dataset page_views using localfs
(("path"="nc1:///home/.../page_views_test.adm"),("format"="adm"));

for $i in dataset page_views
return $i

and fixing the data to be

{"id":1, "user":"keren\\"}

the result is:

{ "id": 1, "user": "keren\\\\" }

So the parsing doesn't break, but '\\' is not considered to be an escaped 
character.

Original comment by westm...@gmail.com on 4 Apr 2014 at 10:05

GoogleCodeExporter commented 9 years ago

Original comment by westm...@gmail.com on 4 Apr 2014 at 10:05

GoogleCodeExporter commented 9 years ago
Fix available in branch westmann/issue754.
Review at http://codereview.appspot.com/84770043

Original comment by westm...@gmail.com on 5 Apr 2014 at 1:34

GoogleCodeExporter commented 9 years ago

Original comment by ker...@gmail.com on 8 Apr 2014 at 7:33