@@ -38,12 +38,12 @@ public class BigQueryDeduplicateSQLBuilderTest {
3838 private Map <String , Expression > selectFields ;
3939 private List <Expression > dedupFields ;
4040 private List <DeduplicateAggregationDefinition .FilterExpression > filterFields ;
41- private DeduplicateAggregationDefinition def ;
41+ private DeduplicateAggregationDefinition fullDefinition ;
42+ private DeduplicateAggregationDefinition onlyDedupFieldsDefinition ;
4243
4344 @ Before
4445 public void setUp () {
4546 factory = new SQLExpressionFactory ();
46- DeduplicateAggregationDefinition .Builder builder = DeduplicateAggregationDefinition .builder ();
4747
4848 // Build aggregation definition
4949 selectFields = new LinkedHashMap <>();
@@ -65,10 +65,17 @@ public void setUp() {
6565 filterFields .add (new DeduplicateAggregationDefinition .FilterExpression (
6666 factory .compile ("f" ), DeduplicateAggregationDefinition .FilterFunction .MIN ));
6767
68- builder .select (selectFields ).dedupOn (dedupFields ).filterDuplicatesBy (filterFields );
69- def = builder .build ();
70-
71- helper = new BigQueryDeduplicateSQLBuilder (def , "select * from tbl" , "ds" , "the_row_number" );
68+ fullDefinition = DeduplicateAggregationDefinition .builder ()
69+ .select (selectFields )
70+ .dedupOn (dedupFields )
71+ .filterDuplicatesBy (filterFields )
72+ .build ();
73+ onlyDedupFieldsDefinition = DeduplicateAggregationDefinition .builder ()
74+ .select (selectFields )
75+ .dedupOn (dedupFields )
76+ .build ();
77+
78+ helper = new BigQueryDeduplicateSQLBuilder (fullDefinition , "select * from tbl" , "ds" , "the_row_number" );
7279 }
7380
7481 @ Test
@@ -114,13 +121,21 @@ public void testGetSelectedFields() {
114121 + "f AS f , "
115122 + "ROW_NUMBER() OVER ( PARTITION BY c , d , e ORDER BY e DESC NULLS LAST , f ASC NULLS LAST ) AS" +
116123 " `the_row_number`" ,
117- helper .getSelectedFields (def ));
124+ helper .getSelectedFields (fullDefinition ));
118125 }
119126
120127 @ Test
121128 public void testGetRowNumColumn () {
122129 Assert .assertEquals ("ROW_NUMBER() OVER ( PARTITION BY c , d , e ORDER BY e DESC NULLS LAST , " +
123- "f ASC NULLS LAST ) AS `the_row_number`" , helper .getRowNumColumn (def ));
130+ "f ASC NULLS LAST ) AS `the_row_number`" ,
131+ helper .getRowNumColumn (fullDefinition ));
132+ }
133+
134+
135+ @ Test
136+ public void testGetRowNumColumnWithoutOrderFields () {
137+ Assert .assertEquals ("ROW_NUMBER() OVER ( PARTITION BY c , d , e ) AS `the_row_number`" ,
138+ helper .getRowNumColumn (onlyDedupFieldsDefinition ));
124139 }
125140
126141 @ Test
0 commit comments