@@ -362,4 +362,90 @@ public void testParquetVersion() {
362362 "Invalid parquet.version: '2.0'. Expected values should be 2.4, 2.6, 1.0" ,
363363 () -> new TableFunctionTable (new ArrayList <>(), properties , new SessionVariable ()));
364364 }
365+
366+ @ Test
367+ public void testPathColumn () {
368+ // Test path_column property parsing
369+ Assertions .assertDoesNotThrow (() -> {
370+ Map <String , String > properties = newProperties ();
371+ properties .put ("path_column" , "_filepath" );
372+ TableFunctionTable table = new TableFunctionTable (properties );
373+
374+ // Check path_column is parsed correctly
375+ Assertions .assertTrue (table .hasPathColumn ());
376+ Assertions .assertEquals ("_filepath" , table .getPathColumnName ());
377+
378+ // Check schema includes path column after columns_from_path
379+ List <Column > schema = table .getFullSchema ();
380+ // Schema: col_int, col_string (from file) + col_path1, col_path2, col_path3 (from path) + _filepath (path column)
381+ Assertions .assertEquals (6 , schema .size ());
382+ Assertions .assertEquals (new Column ("col_int" , IntegerType .INT ), schema .get (0 ));
383+ Assertions .assertEquals (new Column ("col_string" , VarcharType .VARCHAR ), schema .get (1 ));
384+ Assertions .assertEquals (new Column ("col_path1" , StringType .DEFAULT_STRING , true ), schema .get (2 ));
385+ Assertions .assertEquals (new Column ("col_path2" , StringType .DEFAULT_STRING , true ), schema .get (3 ));
386+ Assertions .assertEquals (new Column ("col_path3" , StringType .DEFAULT_STRING , true ), schema .get (4 ));
387+ Assertions .assertEquals (new Column ("_filepath" , StringType .DEFAULT_STRING , true ), schema .get (5 ));
388+ });
389+ }
390+
391+ @ Test
392+ public void testPathColumnWithoutColumnsFromPath () {
393+ // Test path_column without columns_from_path
394+ Assertions .assertDoesNotThrow (() -> {
395+ Map <String , String > properties = new HashMap <>();
396+ properties .put ("path" , "fake://some_bucket/some_path/*" );
397+ properties .put ("format" , "ORC" );
398+ properties .put ("path_column" , "source_file" );
399+ TableFunctionTable table = new TableFunctionTable (properties );
400+
401+ Assertions .assertTrue (table .hasPathColumn ());
402+ Assertions .assertEquals ("source_file" , table .getPathColumnName ());
403+
404+ // Schema: col_int, col_string (from file) + source_file (path column)
405+ List <Column > schema = table .getFullSchema ();
406+ Assertions .assertEquals (3 , schema .size ());
407+ Assertions .assertEquals (new Column ("source_file" , StringType .DEFAULT_STRING , true ), schema .get (2 ));
408+ });
409+ }
410+
411+ @ Test
412+ public void testNoPathColumn () {
413+ // Test without path_column
414+ Assertions .assertDoesNotThrow (() -> {
415+ Map <String , String > properties = newProperties ();
416+ TableFunctionTable table = new TableFunctionTable (properties );
417+
418+ Assertions .assertFalse (table .hasPathColumn ());
419+ Assertions .assertNull (table .getPathColumnName ());
420+ });
421+ }
422+
423+ @ Test
424+ public void testDuplicatePathColumnName () {
425+ // Test duplicate path_column name with file column
426+ Map <String , String > properties = newProperties ();
427+ properties .put ("path_column" , "col_int" );
428+ ExceptionChecker .expectThrowsWithMsg (DdlException .class ,
429+ "Duplicate column name 'col_int'" ,
430+ () -> new TableFunctionTable (properties ));
431+
432+ // Test duplicate path_column name with columns_from_path
433+ properties .put ("path_column" , "col_path1" );
434+ ExceptionChecker .expectThrowsWithMsg (DdlException .class ,
435+ "Duplicate column name 'col_path1'" ,
436+ () -> new TableFunctionTable (properties ));
437+ }
438+
439+ @ Test
440+ public void testPathColumnWithWhitespace () {
441+ // Test path_column with leading/trailing whitespace
442+ Assertions .assertDoesNotThrow (() -> {
443+ Map <String , String > properties = newProperties ();
444+ properties .put ("path_column" , " _filepath " );
445+ TableFunctionTable table = new TableFunctionTable (properties );
446+
447+ Assertions .assertTrue (table .hasPathColumn ());
448+ Assertions .assertEquals ("_filepath" , table .getPathColumnName ());
449+ });
450+ }
365451}
0 commit comments