Beispiel #1
0
 def test_presto_where_latest_partition(self):
     db = mock.Mock()
     db.get_indexes = mock.Mock(return_value=[{"column_names": ["ds", "hour"]}])
     db.get_extra = mock.Mock(return_value={})
     df = pd.DataFrame({"ds": ["01-01-19"], "hour": [1]})
     db.get_df = mock.Mock(return_value=df)
     columns = [{"name": "ds"}, {"name": "hour"}]
     result = PrestoEngineSpec.where_latest_partition(
         "test_table", "test_schema", db, select(), columns
     )
     query_result = str(result.compile(compile_kwargs={"literal_binds": True}))
     self.assertEqual("SELECT  \nWHERE ds = '01-01-19' AND hour = 1", query_result)
 def test_presto_where_latest_partition(self):
     db = mock.Mock()
     db.get_indexes = mock.Mock(return_value=[{
         'column_names': ['ds', 'hour']
     }])
     df = pd.DataFrame({'ds': ['01-01-19'], 'hour': [1]})
     db.get_df = mock.Mock(return_value=df)
     columns = [{'name': 'ds'}, {'name': 'hour'}]
     result = PrestoEngineSpec.where_latest_partition(
         'test_table', 'test_schema', db, select(), columns)
     query_result = str(
         result.compile(compile_kwargs={'literal_binds': True}))
     self.assertEqual('SELECT  \nWHERE ds = \'01-01-19\' AND hour = 1',
                      query_result)