@@ -16,6 +16,7 @@ def normalize_spaces(s: str):
1616class MockDialect (AbstractDialect ):
1717 name = "MockDialect"
1818
19+ PLACEHOLDER_TABLE = None
1920 ROUNDS_ON_PREC_LOSS = False
2021
2122 def quote (self , s : str ) -> str :
@@ -50,6 +51,9 @@ def timestamp_value(self, t: datetime) -> str:
5051 def set_timezone_to_utc (self ) -> str :
5152 return "set timezone 'UTC'"
5253
54+ def optimizer_hints (self , s : str ):
55+ return f"/*+ { s } */ " if s else ""
56+
5357 def load_mixins (self ):
5458 raise NotImplementedError ()
5559
@@ -189,6 +193,22 @@ def test_select_distinct(self):
189193 q = c .compile (t .select (this .b , distinct = True ).select (distinct = False ))
190194 self .assertEqual (q , "SELECT * FROM (SELECT DISTINCT b FROM a) tmp2" )
191195
196+ def test_select_with_optimizer_hints (self ):
197+ c = Compiler (MockDatabase ())
198+ t = table ("a" )
199+
200+ q = c .compile (t .select (this .b , optimizer_hints = 'PARALLEL(a 16)' ))
201+ assert q == "SELECT /*+ PARALLEL(a 16) */ b FROM a"
202+
203+ q = c .compile (t .where (this .b > 10 ).select (this .b , optimizer_hints = 'PARALLEL(a 16)' ))
204+ self .assertEqual (q , "SELECT /*+ PARALLEL(a 16) */ b FROM a WHERE (b > 10)" )
205+
206+ q = c .compile (t .limit (10 ).select (this .b , optimizer_hints = 'PARALLEL(a 16)' ))
207+ self .assertEqual (q , "SELECT /*+ PARALLEL(a 16) */ b FROM (SELECT * FROM a LIMIT 10) tmp1" )
208+
209+ q = c .compile (t .select (this .a ).group_by (this .b ).agg (this .c ).select (optimizer_hints = 'PARALLEL(a 16)' ))
210+ self .assertEqual (q , "SELECT /*+ PARALLEL(a 16) */ * FROM (SELECT b, c FROM (SELECT a FROM point) tmp1 GROUP BY 1) tmp2" )
211+
192212 def test_table_ops (self ):
193213 c = Compiler (MockDatabase ())
194214 a = table ("a" ).select (this .x )
0 commit comments