@@ -7020,13 +7020,19 @@ class Issue588 : public TestSuite {
70207020 insertCsvValues (" test_588_3" , " 1,1\n 2,2\n 3,3" );
70217021 createTable (" test_588_4" , {{" id" , ctx ().int64 ()}, {" D" , ctx ().int64 ()}});
70227022 insertCsvValues (" test_588_4" , " 1,2\n 2,3\n 3,3" );
7023+ createTable (" test_588_5" ,
7024+ {{" id" , ctx ().int32 ()},
7025+ {" s1" , ctx ().extDict (ctx ().text (), 0 )},
7026+ {" s2" , ctx ().extDict (ctx ().text (), 0 )}});
7027+ insertCsvValues (" test_588_5" , " 1,str1,str22\n 2,str2,str22\n 3,str3,str33" );
70237028 }
70247029
70257030 static void TearDownTestSuite () {
70267031 dropTable (" test_588_1" );
70277032 dropTable (" test_588_2" );
70287033 dropTable (" test_588_3" );
70297034 dropTable (" test_588_4" );
7035+ dropTable (" test_588_5" );
70307036 }
70317037};
70327038
@@ -7049,6 +7055,89 @@ TEST_F(Issue588, Reproducer1) {
70497055 auto res3 = runQuery (std::move (dag3));
70507056}
70517057
7058+ TEST_F (Issue588, Reproducer2) {
7059+ QueryBuilder builder (ctx (), getSchemaProvider (), configPtr ());
7060+ auto scan1 = builder.scan (" test_588_1" );
7061+ auto dag1 = scan1.proj ({scan1.ref (" A" ), builder.cst (" str" )}).finalize ();
7062+ auto res1 = runQuery (std::move (dag1));
7063+
7064+ auto scan2 = builder.scan (res1.tableName ());
7065+ auto dag2 = scan2.proj ({0 , 1 }).finalize ();
7066+ auto res2 = runQuery (std::move (dag2));
7067+ }
7068+
7069+ TEST_F (Issue588, Reproducer3) {
7070+ QueryBuilder builder (ctx (), getSchemaProvider (), configPtr ());
7071+ auto scan1 = builder.scan (" test_588_5" );
7072+ auto dict1_type = scan1.ref (" s1" ).type ();
7073+ auto dag1 = scan1
7074+ .proj ({scan1.ref (" id" ),
7075+ builder.ifThenElse (scan1.ref (" id" ).gt (2 ),
7076+ scan1.ref (" s1" ),
7077+ builder.cst (" str" ).cast (dict1_type))})
7078+ .finalize ();
7079+ auto res1 = runQuery (std::move (dag1));
7080+
7081+ auto scan2 = builder.scan (res1.tableName ());
7082+ auto dag2 = scan2.proj ({0 , 1 }).finalize ();
7083+ auto res2 = runQuery (std::move (dag2));
7084+ }
7085+
7086+ TEST_F (Issue588, Reproducer4) {
7087+ QueryBuilder builder (ctx (), getSchemaProvider (), configPtr ());
7088+ auto scan1 = builder.scan (" test_588_5" );
7089+ auto dict1_type = scan1.ref (" s1" ).type ();
7090+ auto dag1 = scan1
7091+ .proj ({scan1.ref (" id" ),
7092+ builder.ifThenElse (scan1.ref (" id" ).gt (2 ),
7093+ scan1.ref (" s1" ),
7094+ scan1.ref (" s2" ).cast (dict1_type))})
7095+ .finalize ();
7096+ auto res1 = runQuery (std::move (dag1));
7097+
7098+ auto scan2 = builder.scan (res1.tableName ());
7099+ auto dag2 = scan2.proj ({0 , 1 }).finalize ();
7100+ auto res2 = runQuery (std::move (dag2));
7101+ }
7102+
7103+ TEST_F (Issue588, Reproducer5) {
7104+ QueryBuilder builder (ctx (), getSchemaProvider (), configPtr ());
7105+ auto scan1 = builder.scan (" test_588_5" );
7106+ auto dict1_type = scan1.ref (" s1" ).type ();
7107+ auto dag1 = scan1
7108+ .proj ({scan1.ref (" id" ),
7109+ builder.ifThenElse (
7110+ scan1.ref (" id" ).gt (2 ),
7111+ scan1.ref (" s1" ),
7112+ builder.ifThenElse (scan1.ref (" id" ).gt (1 ),
7113+ scan1.ref (" s2" ).cast (dict1_type),
7114+ builder.cst (" str" ).cast (dict1_type)))})
7115+ .finalize ();
7116+ auto res1 = runQuery (std::move (dag1));
7117+
7118+ auto scan2 = builder.scan (res1.tableName ());
7119+ auto dag2 = scan2.proj ({0 , 1 }).finalize ();
7120+ auto res2 = runQuery (std::move (dag2));
7121+ }
7122+
7123+ class Issue667 : public TestSuite {
7124+ protected:
7125+ static void SetUpTestSuite () {
7126+ createTable (" test_667" , {{" str" , ctx ().extDict (ctx ().text (), 0 )}});
7127+ insertCsvValues (" test_667" , " 1\n 2\n 3" );
7128+ }
7129+
7130+ static void TearDownTestSuite () {}
7131+ };
7132+
7133+ TEST_F (Issue667, DropInputThenConvertResult) {
7134+ QueryBuilder builder (ctx (), getSchemaProvider (), configPtr ());
7135+ auto dag = builder.scan (" test_667" ).proj (" str" ).finalize ();
7136+ auto res = runQuery (std::move (dag));
7137+ dropTable (" test_667" );
7138+ compare_res_data (res, std::vector<std::string>({" 1" s, " 2" s, " 3" s}));
7139+ }
7140+
70527141TEST_F (QueryBuilderTest, RunOnResult) {
70537142 QueryBuilder builder (ctx (), schema_mgr_, configPtr ());
70547143
0 commit comments