Skip to content

Commit

Permalink
Docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Oct 22, 2024
1 parent e648ecc commit eaf31c3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion blendsql/parse/_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@ def is_blendsql_query(s: str) -> bool:
return s.upper().startswith(("SELECT", "WITH", "{{"))


def is_ingredient_node(node: exp.Expression):
def is_ingredient_node(node: exp.Expression) -> bool:
"""Checks to see if a given node is pointing to an ingredient.
We need to handle both exp.Identifier and exp.Column types below,
since sqlglot will interpret the exp.Function type different depending
on context.
For example:
> SELECT {{B()}} FROM table WHERE a IN {{A()}}
{{B()}} will get parsed as (COLUMN this:
(IDENTIFIER this: {{B()}}, quoted: False))
But {{A()}} will get parsed as (IDENTIFIER this: {{A()}}, quoted: False)
"""
if not isinstance(node, (exp.Identifier, exp.Column)):
return False
if isinstance(node, exp.Column):
Expand Down

0 comments on commit eaf31c3

Please sign in to comment.