@@ -783,7 +783,9 @@ TEST(CatalogTests, Stats) {
783783TEST (ParserAdvanced, JoinAndComplexSelect) {
784784 /* 1. Left Join and multiple joins */
785785 {
786- auto lexer = std::make_unique<Lexer>(" SELECT a.id, b.val FROM t1 LEFT JOIN t2 ON a.id = b.id JOIN t3 ON b.x = t3.x WHERE a.id > 10" );
786+ auto lexer = std::make_unique<Lexer>(
787+ " SELECT a.id, b.val FROM t1 LEFT JOIN t2 ON a.id = b.id JOIN t3 ON b.x = t3.x WHERE "
788+ " a.id > 10" );
787789 Parser parser (std::move (lexer));
788790 auto stmt = parser.parse_statement ();
789791 ASSERT_NE (stmt, nullptr );
@@ -796,7 +798,9 @@ TEST(ParserAdvanced, JoinAndComplexSelect) {
796798
797799 /* 2. Group By and Having */
798800 {
799- auto lexer = std::make_unique<Lexer>(" SELECT cat, SUM(val) FROM items GROUP BY cat HAVING SUM(val) > 1000 ORDER BY cat DESC" );
801+ auto lexer = std::make_unique<Lexer>(
802+ " SELECT cat, SUM(val) FROM items GROUP BY cat HAVING SUM(val) > 1000 ORDER BY cat "
803+ " DESC" );
800804 Parser parser (std::move (lexer));
801805 auto stmt = parser.parse_statement ();
802806 ASSERT_NE (stmt, nullptr );
@@ -814,13 +818,13 @@ TEST(ParserAdvanced, JoinAndComplexSelect) {
814818 auto s1 = parser.parse_statement ();
815819 ASSERT_NE (s1, nullptr );
816820 EXPECT_EQ (s1->type (), StmtType::TransactionBegin);
817-
821+
818822 auto lexer2 = std::make_unique<Lexer>(" COMMIT" );
819823 Parser parser2 (std::move (lexer2));
820824 auto s2 = parser2.parse_statement ();
821825 ASSERT_NE (s2, nullptr );
822826 EXPECT_EQ (s2->type (), StmtType::TransactionCommit);
823-
827+
824828 auto lexer3 = std::make_unique<Lexer>(" ROLLBACK" );
825829 Parser parser3 (std::move (lexer3));
826830 auto s3 = parser3.parse_statement ();
@@ -832,19 +836,19 @@ TEST(ParserAdvanced, JoinAndComplexSelect) {
832836TEST (ParserAdvanced, ParserErrorPaths) {
833837 /* Invalid CREATE syntax */
834838 {
835- auto lexer = std::make_unique<Lexer>(" CREATE TABLE (id INT)" ); // Missing table name
839+ auto lexer = std::make_unique<Lexer>(" CREATE TABLE (id INT)" ); // Missing table name
836840 Parser parser (std::move (lexer));
837841 EXPECT_EQ (parser.parse_statement (), nullptr );
838842 }
839843 /* Invalid JOIN syntax */
840844 {
841- auto lexer = std::make_unique<Lexer>(" SELECT * FROM t1 LEFT t2" ); // Missing JOIN keyword
845+ auto lexer = std::make_unique<Lexer>(" SELECT * FROM t1 LEFT t2" ); // Missing JOIN keyword
842846 Parser parser (std::move (lexer));
843847 EXPECT_EQ (parser.parse_statement (), nullptr );
844848 }
845849 /* Invalid GROUP BY syntax */
846850 {
847- auto lexer = std::make_unique<Lexer>(" SELECT * FROM t1 GROUP cat" ); // Missing BY keyword
851+ auto lexer = std::make_unique<Lexer>(" SELECT * FROM t1 GROUP cat" ); // Missing BY keyword
848852 Parser parser (std::move (lexer));
849853 EXPECT_EQ (parser.parse_statement (), nullptr );
850854 }
@@ -861,14 +865,21 @@ TEST(ExecutionTests, AggregationHaving) {
861865 TransactionManager tm (lm, *catalog, sm, sm.get_log_manager ());
862866 QueryExecutor exec (*catalog, sm, lm, tm);
863867
864- static_cast <void >(exec.execute (*Parser (std::make_unique<Lexer>(" CREATE TABLE having_test (grp INT, val INT)" )).parse_statement ()));
865- static_cast <void >(exec.execute (*Parser (std::make_unique<Lexer>(" INSERT INTO having_test VALUES (1, 10), (1, 20), (2, 5)" )).parse_statement ()));
868+ static_cast <void >(
869+ exec.execute (*Parser (std::make_unique<Lexer>(" CREATE TABLE having_test (grp INT, val INT)" ))
870+ .parse_statement ()));
871+ static_cast <void >(exec.execute (
872+ *Parser (std::make_unique<Lexer>(" INSERT INTO having_test VALUES (1, 10), (1, 20), (2, 5)" ))
873+ .parse_statement ()));
866874
867875 // SELECT grp, SUM(val) FROM having_test GROUP BY grp HAVING SUM(val) > 10
868- auto res = exec.execute (*Parser (std::make_unique<Lexer>(" SELECT grp, SUM(val) FROM having_test GROUP BY grp HAVING SUM(val) > 10" )).parse_statement ());
869-
876+ auto res = exec.execute (
877+ *Parser (std::make_unique<Lexer>(
878+ " SELECT grp, SUM(val) FROM having_test GROUP BY grp HAVING SUM(val) > 10" ))
879+ .parse_statement ());
880+
870881 EXPECT_TRUE (res.success ());
871- ASSERT_EQ (res.row_count (), 1U ); // Only group 1 should pass (sum=30)
882+ ASSERT_EQ (res.row_count (), 1U ); // Only group 1 should pass (sum=30)
872883 EXPECT_STREQ (res.rows ()[0 ].get (0 ).to_string ().c_str (), " 1" );
873884 static_cast <void >(std::remove (" ./test_data/having_test.heap" ));
874885}
@@ -882,10 +893,16 @@ TEST(OperatorTests, AggregateTypes) {
882893 TransactionManager tm (lm, *catalog, sm, sm.get_log_manager ());
883894 QueryExecutor exec (*catalog, sm, lm, tm);
884895
885- static_cast <void >(exec.execute (*Parser (std::make_unique<Lexer>(" CREATE TABLE agg_types (val DOUBLE)" )).parse_statement ()));
886- static_cast <void >(exec.execute (*Parser (std::make_unique<Lexer>(" INSERT INTO agg_types VALUES (10.0), (20.0), (30.0)" )).parse_statement ()));
896+ static_cast <void >(exec.execute (
897+ *Parser (std::make_unique<Lexer>(" CREATE TABLE agg_types (val DOUBLE)" )).parse_statement ()));
898+ static_cast <void >(exec.execute (
899+ *Parser (std::make_unique<Lexer>(" INSERT INTO agg_types VALUES (10.0), (20.0), (30.0)" ))
900+ .parse_statement ()));
887901
888- auto res = exec.execute (*Parser (std::make_unique<Lexer>(" SELECT MIN(val), MAX(val), AVG(val), SUM(val), COUNT(val) FROM agg_types" )).parse_statement ());
902+ auto res = exec.execute (
903+ *Parser (std::make_unique<Lexer>(
904+ " SELECT MIN(val), MAX(val), AVG(val), SUM(val), COUNT(val) FROM agg_types" ))
905+ .parse_statement ());
889906 EXPECT_TRUE (res.success ());
890907 ASSERT_EQ (res.row_count (), 1U );
891908 EXPECT_DOUBLE_EQ (res.rows ()[0 ].get (0 ).to_float64 (), 10.0 );
@@ -905,10 +922,15 @@ TEST(OperatorTests, LimitOffset) {
905922 TransactionManager tm (lm, *catalog, sm, sm.get_log_manager ());
906923 QueryExecutor exec (*catalog, sm, lm, tm);
907924
908- static_cast <void >(exec.execute (*Parser (std::make_unique<Lexer>(" CREATE TABLE lim_off (val INT)" )).parse_statement ()));
909- static_cast <void >(exec.execute (*Parser (std::make_unique<Lexer>(" INSERT INTO lim_off VALUES (1), (2), (3), (4), (5)" )).parse_statement ()));
925+ static_cast <void >(exec.execute (
926+ *Parser (std::make_unique<Lexer>(" CREATE TABLE lim_off (val INT)" )).parse_statement ()));
927+ static_cast <void >(exec.execute (
928+ *Parser (std::make_unique<Lexer>(" INSERT INTO lim_off VALUES (1), (2), (3), (4), (5)" ))
929+ .parse_statement ()));
910930
911- auto res = exec.execute (*Parser (std::make_unique<Lexer>(" SELECT val FROM lim_off ORDER BY val LIMIT 2 OFFSET 2" )).parse_statement ());
931+ auto res = exec.execute (
932+ *Parser (std::make_unique<Lexer>(" SELECT val FROM lim_off ORDER BY val LIMIT 2 OFFSET 2" ))
933+ .parse_statement ());
912934 EXPECT_TRUE (res.success ());
913935 ASSERT_EQ (res.row_count (), 2U );
914936 EXPECT_EQ (res.rows ()[0 ].get (0 ).to_int64 (), 3 );
@@ -925,10 +947,10 @@ TEST(OperatorTests, SeqScanVisibility) {
925947 TransactionManager tm (lm, *catalog, sm, sm.get_log_manager ());
926948 Schema schema;
927949 schema.add_column (" v" , ValueType::TYPE_INT64);
928-
950+
929951 HeapTable table (" vis_test" , sm, schema);
930952 table.create ();
931-
953+
932954 // Use a transaction to insert, ensuring xmin > 0
933955 auto * txn_setup = tm.begin ();
934956 table.insert (Tuple ({Value::make_int64 (1 )}), txn_setup->get_id ());
@@ -938,14 +960,14 @@ TEST(OperatorTests, SeqScanVisibility) {
938960 SeqScanOperator scan (std::make_unique<HeapTable>(" vis_test" , sm, schema), txn, nullptr );
939961 scan.init ();
940962 scan.open ();
941-
963+
942964 Tuple t;
943965 int count = 0 ;
944966 while (scan.next (t)) {
945967 count++;
946968 }
947969 ASSERT_EQ (count, 1 );
948-
970+
949971 static_cast <void >(std::remove (" ./test_data/vis_test.heap" ));
950972}
951973
@@ -962,7 +984,8 @@ TEST(ParserTests, CreateIndexAndAlter) {
962984 EXPECT_STREQ (create_idx->table_name ().c_str (), " users" );
963985 }
964986 {
965- auto lexer = std::make_unique<Lexer>(" SELECT * FROM t WHERE col IS NOT NULL AND id IN (1, 2, 3)" );
987+ auto lexer =
988+ std::make_unique<Lexer>(" SELECT * FROM t WHERE col IS NOT NULL AND id IN (1, 2, 3)" );
966989 Parser parser (std::move (lexer));
967990 auto stmt = parser.parse_statement ();
968991 ASSERT_NE (stmt, nullptr );
0 commit comments