diff --git a/src/sources/dune.py b/src/sources/dune.py index 4d790fd..fe4a695 100644 --- a/src/sources/dune.py +++ b/src/sources/dune.py @@ -225,7 +225,10 @@ def dune_result_to_df(result: ExecutionResult) -> TypedDataFrame: varbinary_cols.extend(_varbinary_cols) unknown_cols.extend(_unknown_cols) - df = pd.DataFrame(result.rows) + df = pd.DataFrame(result.rows, columns=metadata.column_names) + if df.empty: + return TypedDataFrame(df, dtypes) + df = _reformat_varbinary_columns(df, varbinary_cols) df = _reformat_unknown_columns(df, unknown_cols) diff --git a/tests/e2e_test.py b/tests/e2e_test.py index 0441850..f1d5dd7 100644 --- a/tests/e2e_test.py +++ b/tests/e2e_test.py @@ -47,21 +47,21 @@ ], "metadata": { "column_names": [ - "blocktime", + "block_date", "block_number", - "success", + "blocktime", "hash", + "success", "type", - "block_date", "some_number", ], "column_types": [ - "timestamp with time zone", + "date", "bigint", - "boolean", + "timestamp with time zone", "varbinary", + "boolean", "varchar", - "date", "decimal(12, 7)", ], "row_count": 1, @@ -133,6 +133,7 @@ def test_dune_results_to_db(self): "some_number": [12.001], } ) + print(expected) self.assertIsNone( pandas.testing.assert_frame_equal(df, expected, check_dtype=True) )