Skip to content

Commit e4d315d

Browse files
committed
refactor
1 parent 3fe5e29 commit e4d315d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

sqlglot/optimizer/annotate_types.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,23 +345,20 @@ def _get_scope_selects(self, scope: Scope) -> dict[str, dict[str, t.Any]]:
345345
field_col = field.this
346346

347347
first = seq_get(field.expressions, 0)
348-
if not first:
349-
continue
350-
351-
is_pivot_alias = isinstance(first, exp.PivotAlias)
352348

353349
# FOR column type from the alias literal, or VARCHAR if no alias
354-
if is_pivot_alias:
350+
if isinstance(first, exp.PivotAlias):
355351
alias_node = first.args.get("alias")
356352
if alias_node:
357353
col_types[field_col.name] = alias_node.type
354+
src = first.this
358355
else:
359356
col_types[field_col.name] = exp.DataType.build(
360357
"VARCHAR", dialect=self.dialect
361358
)
359+
src = first
362360

363361
# Value column types from the IN source columns
364-
src = first.this if is_pivot_alias else first
365362
src_cols = src.expressions if isinstance(src, exp.Tuple) else [src]
366363
for val_expr in pivot.expressions:
367364
val_cols = (

0 commit comments

Comments
 (0)