Phoenix:将String列转换为Integer列

时间:2017-11-02 12:50:22

标签: hadoop phoenix

我正在寻找内置UDF或任何其他方法,以便在我的凤凰表中将字符串列的值转换为整数,以便使用SELECT和ORDER BY进行排序。我搜索了apache语言手册,但没有用。任何其他建议也欢迎。

实际查询

@Document

我尝试了以下方法,但没有工作

from appium import webdriver
import unittest
import os


class LoginTests(unittest.TestCase):
    def setUp(self):
        desired_caps = {}
        desired_caps['platformName'] = 'iOS'
        desired_caps['platformVersion'] = '11.0'
        desired_caps['deviceName'] = 'iPhone Simulator' # Run on simulator
        desired_caps['bundleId'] = 'com.matchbook.MatchbookApp'
        desired_caps['app'] = os.path.abspath('/Users/majdukovic/Library/Developer/Xcode/DerivedData/MatchBook-bgvchkbwrithuaegnjgpoffewdag/Build/Products/Debug-iphonesimulator/MatchBook.app') # Path to .app
        self.wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps)
        self.wd.implicitly_wait(60)
        loginButton = self.wd.find_element_by_id("JOIN/LOGIN") # Button ID
        self.assertTrue(loginButton.is_displayed())
        loginButton.click()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(LoginTests)
    unittest.TextTestRunner(verbosity=2).run(suite)

2 个答案:

答案 0 :(得分:2)

TO_NUMBER返回十进制,但您可以将结果转换为INTEGER

从MY_DB中选择CAST(TO_NUMBER(MY_COLUMN)作为整数)

答案 1 :(得分:0)

select TO_NUMBER(values) from test_table;

请参阅https://phoenix.apache.org/language/functions.html#to_number