Files
Buffteks-Website/venv/lib/python3.12/site-packages/narwhals/_duckdb/expr_struct.py
2025-05-08 21:10:14 -05:00

21 lines
541 B
Python

from __future__ import annotations
from typing import TYPE_CHECKING
from duckdb import FunctionExpression
from narwhals._duckdb.utils import lit
if TYPE_CHECKING:
from narwhals._duckdb.expr import DuckDBExpr
class DuckDBExprStructNamespace:
def __init__(self, expr: DuckDBExpr) -> None:
self._compliant_expr = expr
def field(self, name: str) -> DuckDBExpr:
return self._compliant_expr._with_callable(
lambda _input: FunctionExpression("struct_extract", _input, lit(name))
).alias(name)