@@ -59,9 +59,25 @@ def dummy_table_1(num_rows: int = 10) -> pa.Table:
5959 """Generate a table with fake data."""
6060 data = {
6161 "lower" : random .choices (string .ascii_lowercase , k = num_rows ),
62- "sequence" : list (range (num_rows )),
63- "upper" : random .choices (string .ascii_uppercase , k = num_rows ),
64- "number" : [random .random () for _ in range (num_rows )],
62+ "some sequence" : list (range (num_rows )),
63+ "UPPER" : random .choices (string .ascii_uppercase , k = num_rows ),
64+ "number 💯" : [random .random () for _ in range (num_rows )],
65+ }
66+ table = pa .table (data )
67+ return table
68+
69+
70+ @pytest .fixture (scope = "module" )
71+ def avro_table (num_rows : int = 10 ) -> pa .Table :
72+ """Generate a table with fake data and Avro compatible column names.
73+
74+ Avro field names are restricted to ``[A-Za-z_][A-Za-z0-9_]*``.
75+ """
76+ data = {
77+ "lower" : random .choices (string .ascii_lowercase , k = num_rows ),
78+ "some_sequence" : list (range (num_rows )),
79+ "UPPER" : random .choices (string .ascii_uppercase , k = num_rows ),
80+ "number_" : [random .random () for _ in range (num_rows )],
6581 }
6682 table = pa .table (data )
6783 return table
@@ -82,9 +98,17 @@ def dummy_table_2(num_rows: int = 13) -> pa.Table:
8298
8399
84100@pytest .fixture (scope = "module" )
85- def full_table (file_params : ff .FileFormat , dummy_table_1 : pa .Table , dummy_table_2 : pa .Table ) -> pa .Table :
101+ def full_table (
102+ file_format : ff .FileFormat ,
103+ file_params : arb .routes .FileReadOptions ,
104+ dummy_table_1 : pa .Table ,
105+ dummy_table_2 : pa .Table ,
106+ avro_table : pa .Table ,
107+ ) -> pa .Table :
86108 """Return the full table on which we are executed queries."""
87- if isinstance (file_params , arb .routes .SqliteReadOptions ):
109+ if file_format == ff .FileFormat .Avro :
110+ return avro_table
111+ if isinstance (file_params , arb .routes .SqliteReadOptions ) and file_params .table_name :
88112 return {
89113 "dummy_table_1" : dummy_table_1 ,
90114 "dummy_table_2" : dummy_table_2 ,
@@ -97,6 +121,7 @@ def table_file(
97121 jp_root_dir : pathlib .Path ,
98122 dummy_table_1 : pa .Table ,
99123 dummy_table_2 : pa .Table ,
124+ avro_table : pa .Table ,
100125 file_format : ff .FileFormat ,
101126 file_params : arb .routes .FileReadOptions ,
102127) -> pathlib .Path :
@@ -105,6 +130,8 @@ def table_file(
105130 table_path = jp_root_dir / f"test.{ str (file_format ).lower ()} "
106131
107132 match file_format :
133+ case ff .FileFormat .Avro :
134+ write_table (avro_table , table_path )
108135 case ff .FileFormat .Csv :
109136 write_table (dummy_table_1 , table_path , delimiter = getattr (file_params , "delimiter" , "," ))
110137 case ff .FileFormat .Sqlite :
0 commit comments