-
Notifications
You must be signed in to change notification settings - Fork 111
[PECOBLR-330] Support for complex params #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
65fe00d
cfc58d6
7271866
7c42faa
8e5038c
ddbe54e
4dd26d9
71be1ed
b032c3f
37c89b8
b2b8a2a
4c36d99
09f4d18
2dc578d
8346de6
c22f6c7
1631142
3178332
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,6 @@ | |
TimestampNTZParameter, | ||
TinyIntParameter, | ||
DecimalParameter, | ||
MapParameter, | ||
ArrayParameter, | ||
) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -5,10 +5,10 @@ | |||
import decimal | ||||
from abc import ABC, abstractmethod | ||||
from collections import OrderedDict, namedtuple | ||||
from collections.abc import Iterable | ||||
from collections.abc import Mapping | ||||
from decimal import Decimal | ||||
from enum import Enum | ||||
from typing import Any, Dict, List, Optional, Union | ||||
from typing import Any, Dict, List, Optional, Union, Sequence | ||||
import re | ||||
|
||||
import lz4.frame | ||||
|
@@ -429,7 +429,7 @@ def user_friendly_error_message(self, no_retry_reason, attempt, elapsed): | |||
# Taken from PyHive | ||||
class ParamEscaper: | ||||
_DATE_FORMAT = "%Y-%m-%d" | ||||
_TIME_FORMAT = "%H:%M:%S.%f" | ||||
_TIME_FORMAT = "%H:%M:%S.%f %z" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Timezone will not be there for TIMESTAMP_NTZ param. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1, would like to know how we've accounted/tested for NTZ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is not there it will be an empty space, there is already a test suite that inserts NTZ and none NTZ and reads back to compare whether it is equal or not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vikrantpuppala @shivam2680 There are already existing tests that insert NTZ and non NTZ values and reads back from table to ensure everything is working as expected -
|
||||
_DATETIME_FORMAT = "{} {}".format(_DATE_FORMAT, _TIME_FORMAT) | ||||
|
||||
def escape_args(self, parameters): | ||||
|
@@ -458,13 +458,22 @@ def escape_string(self, item): | |||
return "'{}'".format(item.replace("\\", "\\\\").replace("'", "\\'")) | ||||
|
||||
def escape_sequence(self, item): | ||||
l = map(str, map(self.escape_item, item)) | ||||
return "(" + ",".join(l) + ")" | ||||
l = map(self.escape_item, item) | ||||
l = list(map(str, l)) | ||||
return "ARRAY(" + ",".join(l) + ")" | ||||
|
||||
def escape_mapping(self, item): | ||||
l = map( | ||||
self.escape_item, | ||||
(element for key, value in item.items() for element in (key, value)), | ||||
) | ||||
l = list(map(str, l)) | ||||
return "MAP(" + ",".join(l) + ")" | ||||
|
||||
def escape_datetime(self, item, format, cutoff=0): | ||||
dt_str = item.strftime(format) | ||||
formatted = dt_str[:-cutoff] if cutoff and format.endswith(".%f") else dt_str | ||||
return "'{}'".format(formatted) | ||||
return "'{}'".format(formatted.strip()) | ||||
jprakash-db marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
def escape_decimal(self, item): | ||||
return str(item) | ||||
|
@@ -476,14 +485,16 @@ def escape_item(self, item): | |||
return self.escape_number(item) | ||||
elif isinstance(item, str): | ||||
return self.escape_string(item) | ||||
elif isinstance(item, Iterable): | ||||
return self.escape_sequence(item) | ||||
elif isinstance(item, datetime.datetime): | ||||
return self.escape_datetime(item, self._DATETIME_FORMAT) | ||||
elif isinstance(item, datetime.date): | ||||
return self.escape_datetime(item, self._DATE_FORMAT) | ||||
elif isinstance(item, decimal.Decimal): | ||||
return self.escape_decimal(item) | ||||
elif isinstance(item, Sequence): | ||||
return self.escape_sequence(item) | ||||
elif isinstance(item, Mapping): | ||||
return self.escape_mapping(item) | ||||
else: | ||||
raise exc.ProgrammingError("Unsupported object {}".format(item)) | ||||
|
||||
|
Uh oh!
There was an error while loading. Please reload this page.