Esempio n. 1
0
    def test_convert_dttm(self):
        dttm = self.get_dttm()

        self.assertEqual(SnowflakeEngineSpec.convert_dttm("DATE", dttm),
                         "TO_DATE('2019-01-02')")

        self.assertEqual(
            SnowflakeEngineSpec.convert_dttm("DATETIME", dttm),
            "CAST('2019-01-02T03:04:05.678900' AS DATETIME)",
        )

        self.assertEqual(
            SnowflakeEngineSpec.convert_dttm("TIMESTAMP", dttm),
            "TO_TIMESTAMP('2019-01-02T03:04:05.678900')",
        )
    def test_convert_dttm(self):
        dttm = self.get_dttm()

        test_cases = {
            "DATE": "TO_DATE('2019-01-02')",
            "DATETIME": "CAST('2019-01-02T03:04:05.678900' AS DATETIME)",
            "TIMESTAMP": "TO_TIMESTAMP('2019-01-02T03:04:05.678900')",
        }

        for type_, expected in test_cases.items():
            self.assertEqual(SnowflakeEngineSpec.convert_dttm(type_, dttm), expected)
Esempio n. 3
0
def test_convert_dttm(actual: str, expected: str, dttm: datetime) -> None:
    from superset.db_engine_specs.snowflake import SnowflakeEngineSpec

    assert SnowflakeEngineSpec.convert_dttm(actual, dttm) == expected