feat:LLM 分析文件并生成结构化建议
This commit is contained in:
@@ -62,6 +62,29 @@ def profile_table(
|
||||
return profile, preview
|
||||
|
||||
|
||||
def read_rows(
|
||||
path: Path,
|
||||
offset: int,
|
||||
limit: int,
|
||||
sort_by: str | None = None,
|
||||
descending: bool = False,
|
||||
) -> list[list[Any]]:
|
||||
"""读一页数据,单元格截断规则与预览相同;sort_by 必须是已校验过的列名,空值排最后"""
|
||||
order = (
|
||||
f" ORDER BY {quote_identifier(sort_by)} {'DESC' if descending else 'ASC'} NULLS LAST"
|
||||
if sort_by
|
||||
else ""
|
||||
)
|
||||
connection = connect({"t": path})
|
||||
try:
|
||||
rows = connection.execute(
|
||||
f"FROM t{order} LIMIT {int(limit)} OFFSET {int(offset)}"
|
||||
).fetchall()
|
||||
finally:
|
||||
connection.close()
|
||||
return [[json_value(value, PREVIEW_CELL_CHARS) for value in row] for row in rows]
|
||||
|
||||
|
||||
def _profile_column(
|
||||
connection: duckdb.DuckDBPyConnection,
|
||||
column: DataColumn,
|
||||
|
||||
Reference in New Issue
Block a user