phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Plamen Paskov <plamen.pas...@next-stream.com>
Subject Re: apache phoenix json api
Date Thu, 14 Apr 2016 11:58:08 GMT
Ah i found the error. It should be "sqlCommands": instead of "sqlCommands",
The documentation syntax is wrong for this request type:
http://calcite.apache.org/avatica/docs/json_reference.html#prepareandexecutebatchrequest

On 14.04.2016 11:09, Plamen Paskov wrote:
> @Josh: thanks for your answer.
>
> Folks,
> I'm trying to prepare and execute batch request with no luck.
> These are the requests i send:
>
> {
>   "request": "openConnection",
>   "connectionId": "2"
> }
>
> {
>   "request": "createStatement",
>   "connectionId": "2"
> }
>
> {
>   "request": "prepareAndExecuteBatch",
>   "connectionId": "2",
>   "statementId": 1,
>   "sqlCommands", [ "UPSERT INTO us_population(STATE,CITY,POPULATION) 
> VALUES('C1','City 1',100000)", "UPSERT INTO 
> us_population(STATE,CITY,POPULATION) VALUES('C2','City 2',1000000)" ]
> }
>
> And this is the response i receive:
>
> <html>
>     <head>
>         <meta http-equiv="Content-Type" 
> content="text/html;charset=ISO-8859-1"/>
>         <title>Error 500 </title>
>     </head>
>     <body>
>         <h2>HTTP ERROR: 500</h2>
>         <p>Problem accessing /. Reason:
>
>             <pre> com.fasterxml.jackson.core.JsonParseException: 
> Unexpected character (',' (code 44)): was expecting a colon to 
> separate field name and value
>  at [Source: java.io.StringReader@41709697; line: 5, column: 17]</pre>
>         </p>
>         <hr />
>         <i>
>             <small>Powered by Jetty://</small>
>         </i>
>     </body>
> </html>
>
>
>
>
> On 13.04.2016 19:27, Josh Elser wrote:
>> For reference materials: definitely check out 
>> https://calcite.apache.org/avatica/
>>
>> While JSON is easy to get started with, there are zero guarantees on 
>> compatibility between versions. If you use protobuf, we should be 
>> able to hide all schema drift from you as a client (e.g. applications 
>> you write against Phoenix 4.7 should continue to work against 4.8, 
>> 4.9, etc).
>>
>> Good luck with the PHP client -- feel free to reach out if you have 
>> more issues. Let us know you have something to shared. I'm sure 
>> others would also find it very useful.
>>
>> F21 wrote:
>>> I am currently building a golang client as well, so I've been looking
>>> the api over the last few weeks.
>>>
>>> I am not sure about the decision to have to create a statement first,
>>> but in terms of go, it fits the sql package very well, where statements
>>> are opened and closed.
>>>
>>> I don't think there are any books (as of yet), but the references and
>>> digging through the code should be quite useful. I also recommend
>>> checking out the avatica project (which is a sub project of calcite)
>>> which is used to power the query server.
>>>
>>> Also, the query server uses protobufs by default now, so it would
>>> probably be better to use that rather than the JSON api.
>>>
>>> On 13/04/2016 10:21 PM, Plamen Paskov wrote:
>>>> thanks for your quick and accurate answer ! it's working now!
>>>> can you give me a brief explanation of why is it to mantain the state
>>>> via the json api so i can better understand how to create a php
>>>> wrapper library. if there are some books or references where i can
>>>> read more about apache phoenix will be very helpful.
>>>> thanks
>>>>
>>>> On 13.04.2016 13:29, F21 wrote:
>>>>> Your PrepareAndExecute request is missing a statementId:
>>>>> https://calcite.apache.org/docs/avatica_json_reference.html#prepareandexecuterequest

>>>>>
>>>>>
>>>>>
>>>>> Before calling PrepareAndExecute, you need to send a CreateStatement
>>>>> request to the server so that it can give you a statementId. Then,
>>>>> use that statementId in your PrepareAndExecute request and all should
>>>>> be fine :)
>>>>>
>>>>>
>>>>> On 13/04/2016 8:24 PM, Plamen Paskov wrote:
>>>>>> Hi guys,
>>>>>> I just setup apache phoenix 4.7 and set the serialization to JSON.
>>>>>> Now i'm trying to run a select statement but what i receive is this:
>>>>>>
>>>>>> {
>>>>>> "response": "executeResults",
>>>>>> "missingStatement": true,
>>>>>> "rpcMetadata": {
>>>>>> "response": "rpcMetadata",
>>>>>> "serverAddress": "ip-172-31-27-198:8765"
>>>>>> },
>>>>>> "results": null
>>>>>> }
>>>>>>
>>>>>> My request looks like this:
>>>>>>
>>>>>> curl -XPOST -H 'request: {"request":"prepareAndExecute",
>>>>>> "connectionId":"1", "sql":"select * from us_population",
>>>>>> "maxRowCount":-1}' http://52.31.63.96:8765/
>>>>>>
>>>>>> Running the select above from the command line is fine and it
>>>>>> returns 2 rows :
>>>>>>
>>>>>> sqlline version 1.1.8
>>>>>> 0: jdbc:phoenix:localhost> select * from us_population;
>>>>>> +-------+------------------------------------------+------------------------------------------+

>>>>>>
>>>>>>
>>>>>> | STATE | CITY | POPULATION |
>>>>>> +-------+------------------------------------------+------------------------------------------+

>>>>>>
>>>>>>
>>>>>> | CA | Los Angeles | 3844829 |
>>>>>> | NY | New York | 8143197 |
>>>>>> +-------+------------------------------------------+------------------------------------------+

>>>>>>
>>>>>>
>>>>>> 2 rows selected (0.087 seconds)
>>>>>>
>>>>>> Can you give me some direction what i'm doing wrong as i'm not java
>>>>>> dev and it's not possible for me to read and understand the source
>>>>>> code.
>>>>>>
>>>>>> Thanks in advance !
>>>>>
>>>>
>>>
>


Mime
View raw message