Line data Source code
1 : #include "absl/status/statusor.h"
2 : #include "backend/schema/schema.h"
3 : #include "backend/storage/duckdb/duckdb_storage.h"
4 : #include "backend/storage/duckdb/duckdb_storage_test_fixture.h"
5 : #include "gtest/gtest.h"
6 :
7 : namespace bigquery_emulator {
8 : namespace backend {
9 : namespace storage {
10 : namespace duckdb {
11 : namespace {
12 :
13 1 : TEST_F(DuckDBStorageTest, RoundTripsColumnDescription) {
14 1 : auto opened = DuckDBStorage::Open(data_dir_.string());
15 2 : ASSERT_TRUE(opened.ok()) << opened.status();
16 1 : auto& store = **opened;
17 :
18 1 : ASSERT_TRUE(store.CreateDataset({"proj", "ds"}, "US").ok());
19 1 : schema::TableSchema schema;
20 1 : schema::ColumnSchema measure;
21 1 : measure.name = "total_sales";
22 1 : measure.type = schema::ColumnType::kInt64;
23 1 : measure.description = "bqemu_measure:SUM(amount):store_id";
24 1 : schema.columns.push_back(measure);
25 :
26 1 : ASSERT_TRUE(store.CreateTable({"proj", "ds", "sales"}, schema).ok());
27 1 : absl::StatusOr<schema::TableSchema> roundtrip =
28 1 : store.GetSchema({"proj", "ds", "sales"});
29 2 : ASSERT_TRUE(roundtrip.ok()) << roundtrip.status();
30 1 : ASSERT_EQ(roundtrip->columns.size(), 1u);
31 1 : EXPECT_EQ(roundtrip->columns[0].description,
32 1 : "bqemu_measure:SUM(amount):store_id");
33 1 : }
34 :
35 : } // namespace
36 : } // namespace duckdb
37 : } // namespace storage
38 : } // namespace backend
39 : } // namespace bigquery_emulator
|