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

Sparml converter: support type StringType and StringType() #638

Closed
wants to merge 7 commits into from
Closed
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
13 changes: 6 additions & 7 deletions onnxmltools/convert/sparkml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def buildInitialTypesSimple(dataframe):


def getTensorTypeFromSpark(sparktype):
if sparktype == "StringType" or sparktype == "StringType()":
return StringTensorType([1, 1])
elif (
if sparktype in ("StringType", "StringType()"):
return StringTensorType([None, 1])
if (
sparktype == "DecimalType"
or sparktype == "DecimalType()"
or sparktype == "DoubleType"
Expand All @@ -34,17 +34,16 @@ def getTensorTypeFromSpark(sparktype):
or sparktype == "BooleanType"
or sparktype == "BooleanType()"
):
return FloatTensorType([1, 1])
else:
raise TypeError("Cannot map this type to Onnx types: " + sparktype)
return FloatTensorType([None, 1])
raise TypeError("Cannot map this type to Onnx types: " + sparktype)


def buildInputDictSimple(dataframe):
import numpy

result = {}
for field in dataframe.schema.fields:
if str(field.dataType) == "StringType":
if str(field.dataType) in ("StringType", "StringType()"):
result[field.name] = dataframe.select(field.name).toPandas().values
else:
result[field.name] = (
Expand Down
Loading