Skip to content

Commit 98f7dee

Browse files
committed
merged skills
addressed remaining comments
1 parent 83d7731 commit 98f7dee

File tree

7 files changed

+836
-70
lines changed

7 files changed

+836
-70
lines changed

python/felderize/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Felderize — Spark SQL to Feldera SQL Translator
22

3-
felderize translates Spark SQL schemas and queries into valid [Feldera](https://www.feldera.com/) SQL using LLM-based translation with optional compiler validation.
3+
felderize attempts to translate Spark SQL schemas and queries into valid [Feldera](https://www.feldera.com/) SQL using LLM-based translation with optional compiler validation.
44

55
## Setup
66

python/felderize/spark/cli.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from felderize.config import Config
1010
from felderize.models import TranslationResult
11-
from felderize.translator import translate_spark_to_feldera
11+
from felderize.translator import split_combined_sql, translate_spark_to_feldera
1212

1313

1414
@click.group()
@@ -44,6 +44,31 @@ def translate(
4444
_print_result(result)
4545

4646

47+
@cli.command("translate-file")
48+
@click.argument("sql_file", type=click.Path(exists=True))
49+
@click.option("--validate", is_flag=True, help="Validate against Feldera instance")
50+
@click.option("--json-output", is_flag=True, help="Output as JSON")
51+
@click.option("--no-docs", is_flag=True, help="Disable Feldera doc inclusion in prompt")
52+
def translate_file(sql_file: str, validate: bool, json_output: bool, no_docs: bool):
53+
"""Translate a single combined Spark SQL file (schema + views) to Feldera SQL."""
54+
config = Config.from_env()
55+
combined_sql = Path(sql_file).read_text()
56+
schema_sql, query_sql = split_combined_sql(combined_sql)
57+
58+
result = translate_spark_to_feldera(
59+
schema_sql,
60+
query_sql,
61+
config,
62+
validate=validate,
63+
include_docs=not no_docs,
64+
)
65+
66+
if json_output:
67+
click.echo(json.dumps(result.to_dict(), indent=2))
68+
else:
69+
_print_result(result)
70+
71+
4772
@cli.command()
4873
@click.argument("data_dir", type=click.Path(exists=True))
4974
@click.option("--validate", is_flag=True, help="Validate against Feldera instance")

0 commit comments

Comments
 (0)