Ejemplo n.º 1
0
def test_apply_top_to_sql_limit(
    app_context: AppContext, limit: int, original: str, expected: str,
) -> None:
    """
    Ensure limits are applied to the query correctly
    """
    from superset.db_engine_specs.teradata import TeradataEngineSpec

    assert TeradataEngineSpec.apply_top_to_sql(original, limit) == expected
Ejemplo n.º 2
0
def test_ParsedQuery_tds_higher_limit(app_context: AppContext) -> None:
    from superset.db_engine_specs.teradata import TeradataEngineSpec, ParsedQueryTeradata

    sql = "SEL TOP 1000 * FROM My_table;"
    limit = 10000

    assert str(TeradataEngineSpec.apply_limit_to_sql(sql, limit, "Database")) == (
        "SEL TOP 1000 * FROM My_table"
    )
Ejemplo n.º 3
0
def test_ParsedQueryTeradata_no_limit(app_context: AppContext) -> None:
    """
    Test the custom ``ParsedQueryTeradata`` that calls ``_extract_limit_from_query_td(``

    The CLass looks for Teradata limit keywords TOP and SAMPLE vs LIMIT in
    other dialects.
    """
    from superset.db_engine_specs.teradata import TeradataEngineSpec

    sql = "SEL * FROM My_table;"
    limit = 1000

    assert str(TeradataEngineSpec.apply_limit_to_sql(
        sql, limit, "Database")) == ("SEL TOP 1000 * FROM My_table")