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

[FSTORE-1466] Refactor type convert out of python engine #1363

Merged
merged 16 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
4 changes: 3 additions & 1 deletion python/hsfs/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
)
initialise_expectation_suite_for_single_expectation_api_message = "Initialize Expectation Suite by attaching to a Feature Group to enable single expectation API"

# Numpy
HAS_ARROW: bool = importlib.util.find_spec("pyarrow") is not None
HAS_PANDAS: bool = importlib.util.find_spec("pandas") is not None
HAS_NUMPY: bool = importlib.util.find_spec("numpy") is not None
HAS_POLARS: bool = importlib.util.find_spec("polars") is not None

# SQL packages
HAS_SQLALCHEMY: bool = importlib.util.find_spec("sqlalchemy") is not None
Expand Down
43 changes: 0 additions & 43 deletions python/hsfs/core/transformation_function_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@
#
from __future__ import annotations

import datetime
from functools import partial
from typing import Dict, Optional, Union

import hsfs
import numpy
from hsfs import (
feature_view,
statistics,
training_dataset,
training_dataset_feature,
transformation_function_attached,
util,
)
from hsfs.core import (
feature_view_api,
Expand Down Expand Up @@ -205,46 +202,6 @@ def populate_builtin_attached_fns(
attached_transformation_fns[ft_name] = transformation_fn
return attached_transformation_fns

@staticmethod
def infer_spark_type(output_type):
if not output_type:
return "STRING" # STRING is default type for spark udfs

if isinstance(output_type, str):
if output_type.endswith("Type()"):
return util.translate_legacy_spark_type(output_type)
output_type = output_type.lower()

if output_type in (str, "str", "string"):
return "STRING"
elif output_type in (bytes, "binary"):
return "BINARY"
elif output_type in (numpy.int8, "int8", "byte", "tinyint"):
return "BYTE"
elif output_type in (numpy.int16, "int16", "short", "smallint"):
return "SHORT"
elif output_type in (int, "int", "integer", numpy.int32):
return "INT"
elif output_type in (numpy.int64, "int64", "long", "bigint"):
return "LONG"
elif output_type in (float, "float"):
return "FLOAT"
elif output_type in (numpy.float64, "float64", "double"):
return "DOUBLE"
elif output_type in (
datetime.datetime,
numpy.datetime64,
"datetime",
"timestamp",
):
return "TIMESTAMP"
elif output_type in (datetime.date, "date"):
return "DATE"
elif output_type in (bool, "boolean", "bool"):
return "BOOLEAN"
else:
raise TypeError("Not supported type %s." % output_type)

@staticmethod
def compute_transformation_fn_statistics(
training_dataset_obj,
Expand Down
Loading
Loading