@@ -53,6 +53,7 @@ TEST(FileSystemCatalogTest, TestDatabaseExists) {
5353 ASSERT_OK_AND_ASSIGN (std::vector<std::string> db_names, catalog.ListDatabases ());
5454 ASSERT_EQ (1 , db_names.size ());
5555 ASSERT_EQ (db_names[0 ], " db1" );
56+ ASSERT_EQ (catalog.GetDatabaseLocation (" db1" ), PathUtil::JoinPath (dir->Str (), " db1.db" ));
5657}
5758
5859TEST (FileSystemCatalogTest, TestInvalidCreateDatabase) {
@@ -297,11 +298,13 @@ TEST(FileSystemCatalogTest, TestCreateTableWhileTableExist) {
297298 arrow::Schema typed_schema (fields);
298299 ::ArrowSchema schema;
299300 ASSERT_TRUE (arrow::ExportSchema (typed_schema, &schema).ok ());
300- ASSERT_OK (catalog.CreateTable (Identifier (" db1" , " tbl1" ), &schema, {" f1" }, {}, options,
301+ Identifier identifier (" db1" , " tbl1" );
302+ ASSERT_OK (catalog.CreateTable (identifier, &schema, {" f1" }, {}, options,
301303 /* ignore_if_exists=*/ true ));
302304 ASSERT_OK_AND_ASSIGN (auto fs, FileSystemFactory::Get (" local" , dir->Str (), {}));
303- ASSERT_OK (fs->Delete (PathUtil::JoinPath (dir->Str (), " db1.db/tbl1/schema/schema-0" )));
304- ASSERT_OK (catalog.CreateTable (Identifier (" db1" , " tbl1" ), &schema, {" f1" }, {}, options,
305+ ASSERT_OK (fs->Delete (
306+ PathUtil::JoinPath (catalog.GetTableLocation (identifier), " schema/schema-0" )));
307+ ASSERT_OK (catalog.CreateTable (identifier, &schema, {" f1" }, {}, options,
305308 /* ignore_if_exists=*/ false ));
306309 }
307310}
@@ -336,13 +339,13 @@ TEST(FileSystemCatalogTest, TestValidateTableSchema) {
336339 arrow::Schema typed_schema (fields);
337340 ::ArrowSchema schema;
338341 ASSERT_TRUE (arrow::ExportSchema (typed_schema, &schema).ok ());
339- ASSERT_OK (catalog.CreateTable (Identifier (" db1" , " tbl1" ), &schema, {" f1" }, {}, options,
342+ Identifier identifier (" db1" , " tbl1" );
343+ ASSERT_OK (catalog.CreateTable (identifier, &schema, {" f1" }, {}, options,
340344 /* ignore_if_exists=*/ false ));
341345
342346 ASSERT_NOK_WITH_MSG (catalog.LoadTableSchema (Identifier (" db0" , " tbl0" )),
343347 " Identifier{database=\' db0\' , table=\' tbl0\' } not exist" );
344- ASSERT_OK_AND_ASSIGN (std::shared_ptr<Schema> table_schema,
345- catalog.LoadTableSchema (Identifier (" db1" , " tbl1" )));
348+ ASSERT_OK_AND_ASSIGN (std::shared_ptr<Schema> table_schema, catalog.LoadTableSchema (identifier));
346349 ASSERT_EQ (0 , table_schema->Id ());
347350 ASSERT_EQ (3 , table_schema->HighestFieldId ());
348351 ASSERT_EQ (1 , table_schema->PartitionKeys ().size ());
@@ -353,8 +356,20 @@ TEST(FileSystemCatalogTest, TestValidateTableSchema) {
353356 std::vector<std::string> expected_field_names = {" f0" , " f1" , " f2" , " f3" };
354357 ASSERT_EQ (field_names, expected_field_names);
355358
359+ FieldType type;
360+ ASSERT_OK_AND_ASSIGN (type, table_schema->GetFieldType (" f0" ));
361+ ASSERT_EQ (type, FieldType::STRING );
362+ ASSERT_OK_AND_ASSIGN (type, table_schema->GetFieldType (" f1" ));
363+ ASSERT_EQ (type, FieldType::INT );
364+ ASSERT_OK_AND_ASSIGN (type, table_schema->GetFieldType (" f2" ));
365+ ASSERT_EQ (type, FieldType::INT );
366+ ASSERT_OK_AND_ASSIGN (type, table_schema->GetFieldType (" f3" ));
367+ ASSERT_EQ (type, FieldType::DOUBLE );
368+ ASSERT_NOK (table_schema->GetFieldType (" f4" ));
369+
356370 ASSERT_OK_AND_ASSIGN (auto fs, FileSystemFactory::Get (" local" , dir->Str (), {}));
357- std::string schema_path = PathUtil::JoinPath (dir->Str (), " db1.db/tbl1/schema/schema-0" );
371+ std::string schema_path =
372+ PathUtil::JoinPath (catalog.GetTableLocation (identifier), " schema/schema-0" );
358373 std::string expected_json_schema;
359374 ASSERT_OK (fs->ReadFile (schema_path, &expected_json_schema));
360375
@@ -366,7 +381,7 @@ TEST(FileSystemCatalogTest, TestValidateTableSchema) {
366381 ASSERT_TRUE (typed_schema.Equals (loaded_schema));
367382
368383 ASSERT_OK (fs->Delete (schema_path));
369- ASSERT_NOK_WITH_MSG (catalog.LoadTableSchema (Identifier ( " db1 " , " tbl1 " ) ),
384+ ASSERT_NOK_WITH_MSG (catalog.LoadTableSchema (identifier ),
370385 " Identifier{database=\' db1\' , table=\' tbl1\' } not exist" );
371386
372387 ASSERT_NOK_WITH_MSG (catalog.LoadTableSchema (Identifier (" db1" , " tbl$11" )),
0 commit comments