mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 09:06:41 +03:00
Functions WIP
This commit is contained in:
parent
969070f1ae
commit
39f34b7c85
|
@ -653,7 +653,31 @@ class F(Cond, FunctionOperatorsMixin):
|
||||||
def tryBase64Decode(s):
|
def tryBase64Decode(s):
|
||||||
return F('tryBase64Decode', s)
|
return F('tryBase64Decode', s)
|
||||||
|
|
||||||
# Functions for searching and replacing in strings
|
@staticmethod
|
||||||
|
def endsWith(s, suffix):
|
||||||
|
return F('endsWith', s, suffix)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def startsWith(s, prefix):
|
||||||
|
return F('startsWith', s, prefix)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def trimLeft(s):
|
||||||
|
return F('trimLeft', s)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def trimRight(s):
|
||||||
|
return F('trimRight', s)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def trimBoth(s):
|
||||||
|
return F('trimBoth', s)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def CRC32(s):
|
||||||
|
return F('CRC32', s)
|
||||||
|
|
||||||
|
# Functions for replacing in strings
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def replace(haystack, pattern, replacement):
|
def replace(haystack, pattern, replacement):
|
||||||
|
|
|
@ -208,7 +208,7 @@ class FuncsTestCase(TestCaseWithData):
|
||||||
self._test_func(F.toRelativeMinuteNum(dt, 'Europe/Athens'), 25770922)
|
self._test_func(F.toRelativeMinuteNum(dt, 'Europe/Athens'), 25770922)
|
||||||
self._test_func(F.toRelativeSecondNum(dt), 1546255353)
|
self._test_func(F.toRelativeSecondNum(dt), 1546255353)
|
||||||
self._test_func(F.toRelativeSecondNum(dt, 'Europe/Athens'), 1546255353)
|
self._test_func(F.toRelativeSecondNum(dt, 'Europe/Athens'), 1546255353)
|
||||||
self._test_func(F.now(), datetime.utcnow().replace(tzinfo=pytz.utc, microsecond=0))
|
self._test_func(F.now(), datetime.utcnow().replace(tzinfo=pytz.utc, microsecond=0)) # FIXME this may fail if the timing is just right
|
||||||
self._test_func(F.today(), date.today())
|
self._test_func(F.today(), date.today())
|
||||||
self._test_func(F.yesterday(), date.today() - timedelta(days=1))
|
self._test_func(F.yesterday(), date.today() - timedelta(days=1))
|
||||||
self._test_func(F.timeSlot(dt), datetime(2018, 12, 31, 11, 0, 0, tzinfo=pytz.utc))
|
self._test_func(F.timeSlot(dt), datetime(2018, 12, 31, 11, 0, 0, tzinfo=pytz.utc))
|
||||||
|
@ -294,6 +294,14 @@ class FuncsTestCase(TestCaseWithData):
|
||||||
self._test_func(F.appendTrailingCharIfAbsent('Hello', '!'), 'Hello!')
|
self._test_func(F.appendTrailingCharIfAbsent('Hello', '!'), 'Hello!')
|
||||||
self._test_func(F.appendTrailingCharIfAbsent('Hello!', '!'), 'Hello!')
|
self._test_func(F.appendTrailingCharIfAbsent('Hello!', '!'), 'Hello!')
|
||||||
self._test_func(F.convertCharset(F.convertCharset('Hello', 'latin1', 'utf16'), 'utf16', 'latin1'), 'Hello')
|
self._test_func(F.convertCharset(F.convertCharset('Hello', 'latin1', 'utf16'), 'utf16', 'latin1'), 'Hello')
|
||||||
|
self._test_func(F.startsWith('aaa', 'aa'), True)
|
||||||
|
self._test_func(F.startsWith('aaa', 'bb'), False)
|
||||||
|
self._test_func(F.endsWith('aaa', 'aa'), True)
|
||||||
|
self._test_func(F.endsWith('aaa', 'bb'), False)
|
||||||
|
self._test_func(F.trimLeft(' abc '), 'abc ')
|
||||||
|
self._test_func(F.trimRight(' abc '), ' abc')
|
||||||
|
self._test_func(F.trimBoth(' abc '), 'abc')
|
||||||
|
self._test_func(F.CRC32('whoops'), 3361378926)
|
||||||
|
|
||||||
def test_base64_functions(self):
|
def test_base64_functions(self):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user