madhushreeag commented on code in PR #40677:
URL: https://github.com/apache/superset/pull/40677#discussion_r3343999516
##########
superset/result_set.py:
##########
@@ -184,6 +186,23 @@ def __init__( # pylint: disable=too-many-locals # noqa:
C901
TypeError, # this is super hackey,
# https://issues.apache.org/jira/browse/ARROW-7855
):
+ col_values = array[column].tolist()
+ if
is_feature_enabled("PRESERVE_NUMERIC_COLUMNS_FOR_SPECIAL_FLOATS"):
+ col_values = [
+ None if isinstance(v, str) and v in _FLOAT_SPECIAL
else v
+ for v in col_values
+ ]
+ try:
+ pa_data.append(pa.array(col_values))
+ continue
Review Comment:
Outdated - Changed the logic
##########
superset/result_set.py:
##########
@@ -277,13 +296,26 @@ def type_generic(
def data_type(self, col_name: str, pa_dtype: pa.DataType) -> Optional[str]:
"""Given a pyarrow data type, Returns a generic database type"""
- if set_type := self._type_dict.get(col_name):
+ set_type = self._type_dict.get(col_name)
+ pa_mapped = self.convert_pa_dtype(pa_dtype)
+
+ # pydruid infers column types from the first row value, so a None or
+ # special-float-string first value causes the column to be labelled
+ # STRING even when the actual data is numeric. When the feature flag
+ # is enabled, prefer PyArrow's inferred type over a cursor-description
+ # STRING so that numeric columns are not misreported.
+ if (
+ is_feature_enabled("PRESERVE_NUMERIC_COLUMNS_FOR_SPECIAL_FLOATS")
+ and set_type == "STRING"
+ and pa_mapped is not None
+ and pa_mapped != "STRING"
+ ):
+ return pa_mapped
+
Review Comment:
Outdated - Changed the logic
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]