def test_where_suggests_columns_functions(expression): suggestions = suggest_type(expression, expression) assert suggestions == (Column(tables=[(None, 'tabl', None)], drop_unique=None), Function(schema=None, filter=None), Alias(aliases=['tabl']), Keyword(last_token='WHERE'))
def test_select_suggests_cols_with_qualified_table_scope(): suggestions = suggest_type('SELECT FROM sch.tabl', 'SELECT ') assert suggestions == (Column(tables=[('sch', 'tabl', None)], drop_unique=None), Function(schema=None, filter=None), Alias(aliases=['tabl']), Keyword(last_token='SELECT'))
def test_join_suggests_cols_with_qualified_table_scope(): expression = 'SELECT * FROM tabl a JOIN tabl b on a.' suggestions = suggest_type(expression, expression) assert suggestions == ( Column(tables=((None, 'tabl', 'a'),), drop_unique=None), Table(schema='a'), View(schema='a'), Function(schema='a', filter=None))
def test_u_suggests_databases(): suggestions = suggest_type('\\u ', '\\u ') assert suggestions == (Database(), )
def test_list_or_show_create_tables(): suggestions = suggest_type('\\dt+', '\\dt+ ') assert suggestions == (Table(schema=None), View(schema=None), Schema())
def test_describe_table(): suggestions = suggest_type('\\dt', '\\dt ') assert suggestions == (Table(schema=None), View(schema=None), Schema())