mistercrunch closed pull request #4124: [Geo] Guard on spatial obj in form_data 
URL: https://github.com/apache/incubator-superset/pull/4124
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/viz.py b/superset/viz.py
index bb052d17ab..e649456de1 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1848,26 +1848,27 @@ def query_obj(self):
     def get_data(self, df):
         fd = self.form_data
         spatial = fd.get('spatial')
-        if spatial.get('type') == 'latlong':
-            df = df.rename(columns={
-                spatial.get('lonCol'): 'lon',
-                spatial.get('latCol'): 'lat'})
-        elif spatial.get('type') == 'delimited':
-            cols = ['lon', 'lat']
-            if spatial.get('reverseCheckbox'):
-                cols.reverse()
-            df[cols] = (
-                df[spatial.get('lonlatCol')]
-                .str
-                .split(spatial.get('delimiter'), expand=True)
-                .astype(np.float64)
-            )
-            del df[spatial.get('lonlatCol')]
-        elif spatial.get('type') == 'geohash':
-            latlong = df[spatial.get('geohashCol')].map(geohash.decode)
-            df['lat'] = latlong.apply(lambda x: x[0])
-            df['lon'] = latlong.apply(lambda x: x[1])
-            del df['geohash']
+        if spatial:
+            if spatial.get('type') == 'latlong':
+                df = df.rename(columns={
+                    spatial.get('lonCol'): 'lon',
+                    spatial.get('latCol'): 'lat'})
+            elif spatial.get('type') == 'delimited':
+                cols = ['lon', 'lat']
+                if spatial.get('reverseCheckbox'):
+                    cols.reverse()
+                df[cols] = (
+                    df[spatial.get('lonlatCol')]
+                    .str
+                    .split(spatial.get('delimiter'), expand=True)
+                    .astype(np.float64)
+                )
+                del df[spatial.get('lonlatCol')]
+            elif spatial.get('type') == 'geohash':
+                latlong = df[spatial.get('geohashCol')].map(geohash.decode)
+                df['lat'] = latlong.apply(lambda x: x[0])
+                df['lon'] = latlong.apply(lambda x: x[1])
+                del df['geohash']
 
         features = []
         for d in df.to_dict(orient='records'):


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to