You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@asterixdb.apache.org by Bhukailas B <bh...@gmail.com> on 2019/07/22 17:14:00 UTC

Rest API : Named and Position based parameters are working

Hello AsterixDB team,

I am posting a request from post man along with named and positioned
parameters. But somewhere I am making a mistake. Could you please help me
with this?

1. Named parameters

*Request*
http://localhost:19002/query/service
statement: use TinySocial; select * from Trailers where carrierId = *$p_str*
;
p_str: WM

*Response:*

{
    "requestID": "7008c7f2-1579-4a81-9cb7-4e9033d42b41",
    "errors": [
        {
            "code": 1,
            "msg": "ASX1086: No value for parameter: $p_str (in line 1, at
column 59)"
        }
    ],
    "status": "fatal",
    "metrics": {
        "elapsedTime": "2.551659ms",
        "executionTime": "2.225153ms",
        "resultCount": 0,
        "resultSize": 0,
        "processedObjects": 0,
        "errorCount": 1
    }
}


2. Positioned parameters

*Request*
http://localhost:19002/query/service
statement: use TinySocial; select * from Trailers where carrierId = *?*;
args: ['WM']

*Response*

{
    "requestID": "0a5971e6-c749-46a5-bd62-c1bd68e0f437",
    "errors": [
        {
            "code": 1,
            "msg": "ASX1086: No value for parameter: $p_str (in line 1, at
column 59)"
        }
    ],
    "status": "fatal",
    "metrics": {
        "elapsedTime": "3.27977ms",
        "executionTime": "2.913792ms",
        "resultCount": 0,
        "resultSize": 0,
        "processedObjects": 0,
        "errorCount": 1
    }
}

Thank you,
Bhukailas

Re: Rest API : Named and Position based parameters are working

Posted by Ian Maxon <im...@uci.edu>.
Hey Bhukailas,
I am not sure how you are formatting your request exactly, it isn't
clear to me from the example. It needs to be either a JSON object or a
list of comma delimited arguments like "statement=foo,..."  However,
here's an example of the request format in JSON using curl to send it:

1. Named params:
curl -X POST -H "Content-Type: application/json"
"localhost:19002/query/service" --data '{"statement": "SELECT * from
`Metadata`.`Dataset` AS ds where ds.DatasetName = $name", "$name":
"Index"}'

{
    "requestID": "6706a762-4537-49b8-b0d8-a7c7e3889777",
    "signature": {
        "*": "*"
    },
    "results": [ { "ds": { "DataverseName": "Metadata", "DatasetName":
"Index", "DatatypeDataverseName": "Metadata", "DatatypeName":
"IndexRecordType", "DatasetType": "INTERNAL", "GroupName":
"MetadataGroup", "CompactionPolicy": "prefix",
"CompactionPolicyProperties": [ { "Name":
"max-mergable-component-size", "Value": "1073741824" }, { "Name":
"max-tolerance-component-count", "Value": "5" } ], "InternalDetails":
{ "FileStructure": "BTREE", "PartitioningStrategy": "HASH",
"PartitioningKey": [ [ "DataverseName" ], [ "DatasetName" ], [
"IndexName" ] ], "PrimaryKey": [ [ "DataverseName" ], [ "DatasetName"
], [ "IndexName" ] ], "Autogenerated": false }, "Hints": [  ],
"Timestamp": "Fri Jul 12 00:45:40 PDT 2019", "DatasetId": 4,
"PendingOp": 0 } }
 ]
    ,
    "plans":{},
    "status": "success",
    "metrics": {
        "elapsedTime": "90.258043ms",
        "executionTime": "87.362035ms",
        "resultCount": 1,
        "resultSize": 736,
        "processedObjects": 15
    }
}

2. Positional params:
 curl -X POST -H "Content-Type: application/json"
"localhost:19002/query/service" --data '{"statement": "SELECT * from
`Metadata`.`Dataset` AS ds where ds.DatasetName = ? OR ds.DatasetName=
?", "args":["Index","Feed"]}'
{
    "requestID": "82ac8d5e-0626-4326-92bb-aee6a5f16688",
    "signature": {
        "*": "*"
    },
    "results": [ { "ds": { "DataverseName": "Metadata", "DatasetName":
"Index", "DatatypeDataverseName": "Metadata", "DatatypeName":
"IndexRecordType", "DatasetType": "INTERNAL", "GroupName":
"MetadataGroup", "CompactionPolicy": "prefix",
"CompactionPolicyProperties": [ { "Name":
"max-mergable-component-size", "Value": "1073741824" }, { "Name":
"max-tolerance-component-count", "Value": "5" } ], "InternalDetails":
{ "FileStructure": "BTREE", "PartitioningStrategy": "HASH",
"PartitioningKey": [ [ "DataverseName" ], [ "DatasetName" ], [
"IndexName" ] ], "PrimaryKey": [ [ "DataverseName" ], [ "DatasetName"
], [ "IndexName" ] ], "Autogenerated": false }, "Hints": [  ],
"Timestamp": "Fri Jul 12 00:45:40 PDT 2019", "DatasetId": 4,
"PendingOp": 0 } }
, { "ds": { "DataverseName": "Metadata", "DatasetName": "Feed",
"DatatypeDataverseName": "Metadata", "DatatypeName": "FeedRecordType",
"DatasetType": "INTERNAL", "GroupName": "MetadataGroup",
"CompactionPolicy": "prefix", "CompactionPolicyProperties": [ {
"Name": "max-mergable-component-size", "Value": "1073741824" }, {
"Name": "max-tolerance-component-count", "Value": "5" } ],
"InternalDetails": { "FileStructure": "BTREE", "PartitioningStrategy":
"HASH", "PartitioningKey": [ [ "DataverseName" ], [ "FeedName" ] ],
"PrimaryKey": [ [ "DataverseName" ], [ "FeedName" ] ],
"Autogenerated": false }, "Hints": [  ], "Timestamp": "Fri Jul 12
00:45:40 PDT 2019", "DatasetId": 10, "PendingOp": 0 } }
 ]
    ,
    "plans":{},
    "status": "success",
    "metrics": {
        "elapsedTime": "315.841631ms",
        "executionTime": "314.47834ms",
        "resultCount": 2,
        "resultSize": 1431,
        "processedObjects": 15
    }
}


On Mon, Jul 22, 2019 at 5:54 PM Bhukailas B <bh...@gmail.com> wrote:
>
> Hello AsterixDB team,
>
> I am posting a request from post man along with named and positioned
> parameters. But somewhere I am making a mistake. Could you please help me
> with this?
>
> 1. Named parameters
>
> *Request*
> http://localhost:19002/query/service
> statement: use TinySocial; select * from Trailers where carrierId = *$p_str*
> ;
> p_str: WM
>
> *Response:*
>
> {
>     "requestID": "7008c7f2-1579-4a81-9cb7-4e9033d42b41",
>     "errors": [
>         {
>             "code": 1,
>             "msg": "ASX1086: No value for parameter: $p_str (in line 1, at
> column 59)"
>         }
>     ],
>     "status": "fatal",
>     "metrics": {
>         "elapsedTime": "2.551659ms",
>         "executionTime": "2.225153ms",
>         "resultCount": 0,
>         "resultSize": 0,
>         "processedObjects": 0,
>         "errorCount": 1
>     }
> }
>
>
> 2. Positioned parameters
>
> *Request*
> http://localhost:19002/query/service
> statement: use TinySocial; select * from Trailers where carrierId = *?*;
> args: ['WM']
>
> *Response*
>
> {
>     "requestID": "0a5971e6-c749-46a5-bd62-c1bd68e0f437",
>     "errors": [
>         {
>             "code": 1,
>             "msg": "ASX1086: No value for parameter: $p_str (in line 1, at
> column 59)"
>         }
>     ],
>     "status": "fatal",
>     "metrics": {
>         "elapsedTime": "3.27977ms",
>         "executionTime": "2.913792ms",
>         "resultCount": 0,
>         "resultSize": 0,
>         "processedObjects": 0,
>         "errorCount": 1
>     }
> }
>
> Thank you,
> Bhukailas