diff --git a/setup.py b/setup.py index 48f632a..f2b74f4 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ this_directory = Path(__file__).parent long_description = (this_directory / "README.md").read_text() -VERSION = '0.0.37' +VERSION = '0.0.38' setup(name='snowpark_extensions', version=VERSION, @@ -14,7 +14,7 @@ long_description_content_type='text/markdown', url='http://github.com/MobilizeNet/snowpark-extensions-py', author='mauricio.rojas', - install_requires=['snowflake-snowpark-python[pandas]==1.11.1','jinja2'], + install_requires=['snowflake-snowpark-python[pandas]==1.14.0','jinja2'], author_email='mauricio.rojas@mobilize.net', packages=['snowpark_extensions'], zip_safe=False) diff --git a/snowpark_extensions/dataframe_extensions.py b/snowpark_extensions/dataframe_extensions.py index 287f191..a1781eb 100644 --- a/snowpark_extensions/dataframe_extensions.py +++ b/snowpark_extensions/dataframe_extensions.py @@ -231,19 +231,6 @@ def group_by_pivot(self,pivot_col): return GroupByPivot(self, pivot_col) RelationalGroupedDataFrame.pivot = group_by_pivot - RelationalGroupedDataFrame._applyInPandas = RelationalGroupedDataFrame.apply_in_pandas - - def applyInPandas(self,func,schema=None,output_schema=None,**kwargs): - output_schema = output_schema or schema - input_columns = [x.name for x in self._df.schema.fields] - def func_wrapper(pdf): - pdf.columns = input_columns - return func(pdf) - if isinstance(output_schema, str): - output_schema = schema_str_to_schema(output_schema) - return self._applyInPandas(func_wrapper,output_schema=output_schema,**kwargs) - - RelationalGroupedDataFrame.applyInPandas = applyInPandas ###### HELPER END diff --git a/snowpark_extensions/types_extensions.py b/snowpark_extensions/types_extensions.py index 96191e2..67a82c6 100644 --- a/snowpark_extensions/types_extensions.py +++ b/snowpark_extensions/types_extensions.py @@ -11,4 +11,14 @@ def schema__get_item__(self,index): else: return self.fields[index] StructType.__getitem__ = schema__get_item__ - StructField.dtype = property(lambda self: self.datatype) \ No newline at end of file + StructField.dtype = property(lambda self: self.datatype) + from snowflake.snowpark._internal.type_utils import convert_sf_to_sp_type + def fromJson(cls, json: dict) -> StructField: + return StructField( + json["name"], + convert_sf_to_sp_type(json["type"]), + json.get("nullable", True), + json.get("metadata"), + ) + StructField.fromJson = fromJson + StructType.fromJson = lambda cls,json: StructType([StructField.fromJson(f) for f in json["fields"]]) \ No newline at end of file