Esempio n. 1
0
def test_transform_syntax():
    # test data sources and nested
    good_single_syntax("a = transform ", ["", "a,b", "(transform using x)"],
                       "using x",
                       ignore_case=True,
                       simple_assign=True)
    # extensions
    good_single_syntax("transform", ["prepartition by x"],
                       " using ", ["x", "x.Y.z"],
                       ignore_case=True,
                       simple_assign=True)
    # params
    good_single_syntax("a= transform using x", ["", "params a:10,b=\"20\""],
                       ignore_case=True,
                       simple_assign=True)
    # params
    good_single_syntax("a= transform using x", ["params"], [
        "{a:10,b:{x:10,y:true,z:false,w:null}}", "(a=10,b=True)",
        "(a:10,b:{x:10,y:true,z:false,w:null})"
    ],
                       ignore_case=True,
                       simple_assign=True)
    # schemas
    good_single_syntax("a= transform using x",
                       ["", "schema a : int,b:{x:int,y:[str]},c:[int]"],
                       ignore_case=True,
                       simple_assign=True)
    # schemas bad list
    bad_single_syntax("a= transform using x schema a:int,c:[int,str]",
                      ignore_case=True,
                      simple_assign=True)
Esempio n. 2
0
def test_assign_syntax():
    # simple assign not enabled
    bad_single_syntax("a = select a where a==10", ignore_case=True, simple_assign=False)
    # when simple assign enabled, comparison using = is still valid
    good_single_syntax("a = select a where a=10", ignore_case=True, simple_assign=True)
    good_single_syntax("a = select a where a==10", ignore_case=True, simple_assign=True)
    # multiple expression test
    good_syntax(
        """
        a = select a where a==10
        b=select x""",
        ignore_case=True,
        simple_assign=True,
    )
Esempio n. 3
0
def test_select_syntax():
    # TODO: add a??
    bad_single_syntax("SELECT a FROM", ignore_case=False, ansi_sql=True)
    good_single_syntax(["a:=", ""], "SELECT a", ["FROM sx"], ignore_case=False)
    bad_single_syntax('select a', ["from sx"], ignore_case=False)
    good_single_syntax('select a', ["from sx"], ["where a=10 and a==10"],
                       ignore_case=True)

    # nested
    good_single_syntax("SELECT a FROM (TRANSFORM USING x)", ["AS t"],
                       ignore_case=False)
    good_single_syntax("""
    SELECT a FROM 
        (TRANSFORM USING x) AS x INNER JOIN (TRANSFORM USING x) AS y
        ON x.a = b.a
    """,
                       ignore_case=False)

    # no from
    good_syntax("select *", ignore_case=True, simple_assign=True)
    good_syntax("select * where a=100", ignore_case=True, simple_assign=True)