mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
[bugfix] TIMESTAMP not detected as date (#5629)
* [bugfix] TIMESTAMP not detected as date * minor tweak
This commit is contained in:
committed by
GitHub
parent
85a6da19ee
commit
4c2be71e83
@@ -134,8 +134,12 @@ class SupersetDataFrame(object):
|
||||
|
||||
@classmethod
|
||||
def is_date(cls, dtype):
|
||||
if dtype.name:
|
||||
return dtype.name.startswith('datetime')
|
||||
if dtype and dtype.name:
|
||||
return any([
|
||||
dtype.name.lower().startswith(s)
|
||||
for s in ['date', 'time']
|
||||
])
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def is_dimension(cls, dtype, column_name):
|
||||
|
||||
@@ -4,6 +4,8 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import numpy as np
|
||||
|
||||
from superset.dataframe import dedup, SupersetDataFrame
|
||||
from superset.db_engine_specs import BaseEngineSpec
|
||||
from .base_tests import SupersetTestCase
|
||||
@@ -118,6 +120,13 @@ class SupersetDataFrameTestCase(SupersetTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_is_date(self):
|
||||
f = SupersetDataFrame.is_date
|
||||
self.assertEquals(f(np.dtype('M')), True)
|
||||
|
||||
self.assertEquals(f(None), False)
|
||||
self.assertEquals(f(np.dtype(np.int32)), False)
|
||||
|
||||
def test_dedup_with_data(self):
|
||||
data = [
|
||||
('a', 1),
|
||||
|
||||
Reference in New Issue
Block a user