v3io, DateTime "GetItems: invalid value of JSON request parameter"

61 views Asked by At

I got this error during filtering of values in NoSQLTarget via v3io:

...
raise HttpResponseError("Request failed with status {0}: {1}".format(self.status_code, self.body))
v3io.dataplane.response.HttpResponseError: Request failed with status 400: b'{\n\t"ErrorCode": -318767104,\n\t"ErrorMessage": "GetItems: invalid value of JSON request parameter \'FilterExpression\'"\n}'
2023-05-17 13:53:53,531 [warning] Response error: Request failed with status 400: b'{\n\t"ErrorCode": -318767104,\n\t"ErrorMessage": "GetItems: invalid value of JSON request parameter \'FilterExpression\'"\n}'

This is the source code:

import v3io
from datetime import datetime
... 
v3io_client = v3io.dataplane.Client(endpoint='https://webapi...nonprod',
                        access_key="7e1168ad-xxxx-xxxx-xxxx-xxxxxxxxxxxxx")
response = v3io_client.kv.new_cursor(container="projects",
                        table_path='/v3io-py-example2/FeatureStore/nosql/.../168432561111_888/',
                        filter_expression="whn > " + datetime(2018, 10, 22, 0, 0))

for item in response.all():
    print(item)

It seems that the issue is only in case of filter to a feature with datetime type. Do you know, how to solve it or do you have work-around?

1

There are 1 answers

0
JIST On BEST ANSWER

The v3io supports for filtering timestamp instead of datetime (it means, you have to do conversion and use str(dt.timestamp()) + “:0”). I updated your code a bit:

import v3io
from datetime import datetime
... 
v3io_client = v3io.dataplane.Client(endpoint='https://webapi...nonprod',
                        access_key="7e1168ad-xxxx-xxxx-xxxx-xxxxxxxxxxxxx")

dt = datetime(2018, 10, 22, 0, 0)
response = v3io_client.kv.new_cursor(container="projects",
                        table_path='/v3io-py-example2/FeatureStore/nosql/.../168432561111_888/',
                        filter_expression="whn > " + str(dt.timestamp()) + “:0”)

for item in response.all():
    print(item)