File: test_drill.py

package info (click to toggle)
sqlglot 28.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,816 kB
  • sloc: python: 86,744; sql: 22,739; makefile: 48
file content (25 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from tests.dialects.test_dialect import Validator


class TestDrill(Validator):
    dialect = "drill"

    def test_drill(self):
        self.validate_identity(
            "SELECT * FROM table(dfs.`test_data.xlsx`(type => 'excel', sheetName => 'secondSheet'))"
        )
        self.validate_identity(
            "SELECT * FROM (SELECT * FROM t) PIVOT(avg(c1) AS ac1 FOR c2 IN ('V' AS v))",
        )

        self.validate_all(
            "SELECT '2021-01-01' + INTERVAL 1 MONTH",
            write={
                "drill": "SELECT '2021-01-01' + INTERVAL '1' MONTH",
                "mysql": "SELECT '2021-01-01' + INTERVAL '1' MONTH",
            },
        )

    def test_analyze(self):
        self.validate_identity("ANALYZE TABLE tbl COMPUTE STATISTICS")
        self.validate_identity("ANALYZE TABLE tbl COMPUTE STATISTICS SAMPLE 5 PERCENT")