Ejemplo n.º 1
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,
    )
Ejemplo n.º 2
0
def test_schema_syntax():
    good_syntax(
        [
            "*",
            "a:int",
            "a:int,*",
            "*,a:int",
            "a:int,*,b:int",
            "*-a,b",
            "*~c",
            "*+c:str,d:int",
            "*,k:str+a:str,b:str-c~x",
        ],
        ignore_case=False,
        rule="fugueWildSchema",
    )
Ejemplo 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)
Ejemplo n.º 4
0
def test_schema_syntax():
    good_syntax(
        ["*", "a:int", "a:int,*", "*,a:int", "a:int,*,b:int"],
        ignore_case=False,
        rule="fugueWildSchema",
    )