Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry client support SparkSqlSource #970

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion feathr_project/feathr/registry/_feathr_registry_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from feathr.definition.feature import Feature, FeatureBase
from feathr.definition.feature_derivations import DerivedFeature
from feathr.definition.repo_definitions import RepoDefinitions
from feathr.definition.source import GenericSource, HdfsSource, InputContext, JdbcSource, SnowflakeSource, Source
from feathr.definition.source import GenericSource, HdfsSource, InputContext, JdbcSource, SnowflakeSource, Source, SparkSqlSource
from feathr.definition.transformation import ExpressionTransformation, Transformation, WindowAggTransformation
from feathr.definition.typed_key import TypedKey
from feathr.registry.feature_registry import FeathrRegistry
Expand Down Expand Up @@ -260,6 +260,9 @@ def source_to_def(v: Source) -> dict:
elif isinstance(v, GenericSource):
ret = v.to_dict()
ret["name"] = v.name
elif isinstance(v, SparkSqlSource):
ret = v.to_dict()
ret["name"] = v.name
else:
raise ValueError(f"Unsupported source type {v.__class__}")
if hasattr(v, "preprocessing") and v.preprocessing:
Expand All @@ -281,6 +284,17 @@ def dict_to_source(v: dict) -> Source:
source = None
if type == INPUT_CONTEXT:
source = InputContext()
elif type == "sparksql":
source = SparkSqlSource(name=v["attributes"]["name"],
sql=v["attributes"].get("sql"),
table=v["attributes"].get("table"),
preprocessing=_correct_function_indentation(
v["attributes"].get("preprocessing")),
event_timestamp_column=v["attributes"].get(
"eventTimestampColumn"),
timestamp_format=v["attributes"].get(
"timestampFormat"),
registry_tags=v["attributes"].get("tags", {}))
elif type == "jdbc":
source = JdbcSource(name=v["attributes"]["name"],
url=v["attributes"].get("url"),
Expand Down