@@ -788,6 +788,78 @@ func TestChangefeedBasicConfluentKafka(t *testing.T) {
788
788
cdcTest (t , testFn , feedTestForceSink ("kafka" ))
789
789
}
790
790
791
+ func TestChangefeedQuotedTableNameTopicName (t * testing.T ) {
792
+ defer leaktest .AfterTest (t )()
793
+ defer log .Scope (t ).Close (t )
794
+
795
+ testFn := func (t * testing.T , s TestServer , f cdctest.TestFeedFactory ) {
796
+ sqlDB := sqlutils .MakeSQLRunner (s .DB )
797
+ sqlDB .Exec (t , `CREATE TABLE "MyTable" (a INT PRIMARY KEY, b STRING)` )
798
+ sqlDB .Exec (t , `INSERT INTO "MyTable" VALUES (0, 'initial')` )
799
+ sqlDB .Exec (t , `UPSERT INTO "MyTable" VALUES (0, 'updated')` )
800
+
801
+ foo := feed (t , f ,
802
+ `CREATE CHANGEFEED FOR d.public."MyTable" WITH diff, full_table_name` )
803
+ defer closeFeed (t , foo )
804
+
805
+ // The topic name should be d.public.MyTable and not d.public._u0022_MyTable_u0022_
806
+ // or d.public."MyTable".
807
+ assertPayloads (t , foo , []string {
808
+ `d.public.MyTable: [0]->{"after": {"a": 0, "b": "updated"}, "before": null}` ,
809
+ })
810
+ }
811
+
812
+ cdcTest (t , testFn )
813
+ }
814
+
815
+ // TestChangefeedQuotedIdentifiersTopicName is similar to
816
+ // TestChangefeedQuotedTableNameTopicName, but for quoted identifiers
817
+ // in the SELECT clause instead of the table name.
818
+ func TestChangefeedQuotedIdentifiersTopicName (t * testing.T ) {
819
+ defer leaktest .AfterTest (t )()
820
+ defer log .Scope (t ).Close (t )
821
+
822
+ testFn := func (t * testing.T , s TestServer , f cdctest.TestFeedFactory ) {
823
+ sqlDB := sqlutils .MakeSQLRunner (s .DB )
824
+
825
+ sqlDB .Exec (t , `CREATE TABLE mytable (
826
+ id INT PRIMARY KEY,
827
+ "SomeField" JSONB,
828
+ "AnotherField" JSONB
829
+ )` )
830
+
831
+ sqlDB .Exec (t , `INSERT INTO mytable VALUES (
832
+ 1,
833
+ '{"PropA": "value1", "prop_b": "value2"}'::jsonb,
834
+ '{"PropC": "value3", "prop_d": "value4"}'::jsonb
835
+ )` )
836
+
837
+ sqlDB .Exec (t , `INSERT INTO mytable VALUES (
838
+ 2,
839
+ '{"PropA": "value5", "prop_b": "value6"}'::jsonb,
840
+ '{"PropC": "value7", "prop_d": "value8"}'::jsonb
841
+ )` )
842
+
843
+ foo := feed (t , f , `CREATE CHANGEFEED WITH diff, full_table_name, on_error=pause, envelope=wrapped AS SELECT
844
+ id,
845
+ "SomeField"->>'PropA' AS "PropA",
846
+ "SomeField"->>'prop_b' AS "PropB",
847
+ "AnotherField"->>'PropC' AS "PropC",
848
+ "AnotherField"->>'prop_d' AS "PropD"
849
+ FROM public.mytable` )
850
+ defer closeFeed (t , foo )
851
+
852
+ // The topic should show up as d.public.mytable and not as
853
+ // d.public.u0022_mytable_u0022 or d.public."MyTable".
854
+ assertPayloads (t , foo , []string {
855
+ `d.public.mytable: [1]->{"after": {"PropA": "value1", "PropB": "value2", "PropC": "value3", "PropD": "value4", "id": 1}, "before": null}` ,
856
+ `d.public.mytable: [2]->{"after": {"PropA": "value5", "PropB": "value6", "PropC": "value7", "PropD": "value8", "id": 2}, "before": null}` ,
857
+ })
858
+ }
859
+
860
+ cdcTest (t , testFn )
861
+ }
862
+
791
863
func TestChangefeedDiff (t * testing.T ) {
792
864
defer leaktest .AfterTest (t )()
793
865
defer log .Scope (t ).Close (t )
@@ -972,7 +1044,7 @@ func TestChangefeedFullTableName(t *testing.T) {
972
1044
sqlDB .Exec (t , `INSERT INTO foo VALUES (1, 'a')` )
973
1045
974
1046
t .Run (`envelope=row` , func (t * testing.T ) {
975
- foo := feed (t , f , `CREATE CHANGEFEED FOR foo WITH full_table_name` , optOutOfMetamorphicEnrichedEnvelope { reason : "broken for webhook; see #145927" } )
1047
+ foo := feed (t , f , `CREATE CHANGEFEED FOR foo WITH full_table_name` )
976
1048
defer closeFeed (t , foo )
977
1049
assertPayloads (t , foo , []string {`d.public.foo: [1]->{"after": {"a": 1, "b": "a"}}` })
978
1050
})
0 commit comments