50-unsupported-types.td 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # These goal of these tests is to exercise what isn't supported in the SQL
  10. # Server source and that we properly handle these scenarios.
  11. # Setup SQL Server state.
  12. #
  13. # Create a table that has CDC enabled.
  14. $ sql-server-connect name=sql-server
  15. server=tcp:sql-server,1433;IntegratedSecurity=true;TrustServerCertificate=true;User ID=${arg.default-sql-server-user};Password=${arg.default-sql-server-password}
  16. $ sql-server-execute name=sql-server
  17. DROP DATABASE IF EXISTS test_50;
  18. CREATE DATABASE test_50;
  19. USE test_50;
  20. EXEC sys.sp_cdc_enable_db;
  21. ALTER DATABASE test_50 SET ALLOW_SNAPSHOT_ISOLATION ON;
  22. CREATE TABLE table_text (good varchar(128), bad text);
  23. EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_text', @role_name = 'SA', @supports_net_changes = 0;
  24. INSERT INTO table_text VALUES ('i work', 'i do not'), ('maybe me', 'not so much');
  25. CREATE TABLE table_image (good int, bad image);
  26. EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_image', @role_name = 'SA', @supports_net_changes = 0;
  27. INSERT INTO table_image VALUES (42, NULL);
  28. CREATE TABLE table_geography (good int, bad geography);
  29. EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_geography', @role_name = 'SA', @supports_net_changes = 0;
  30. INSERT INTO table_geography VALUES (42, NULL);
  31. CREATE TABLE table_geometry (good int, bad geometry);
  32. EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_geometry', @role_name = 'SA', @supports_net_changes = 0;
  33. INSERT INTO table_geometry VALUES (42, NULL);
  34. CREATE TABLE table_varchar_max (good int, bad varchar(max));
  35. EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_varchar_max', @role_name = 'SA', @supports_net_changes = 0;
  36. INSERT INTO table_varchar_max VALUES (42, NULL);
  37. CREATE TABLE dummy (data int);
  38. EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'dummy', @role_name = 'SA', @supports_net_changes = 0;
  39. # Exercise Materialize.
  40. > CREATE SECRET IF NOT EXISTS sql_server_pass AS '${arg.default-sql-server-password}'
  41. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  42. ALTER SYSTEM SET enable_sql_server_source = true;
  43. > CREATE CONNECTION sql_server_test_50_connection TO SQL SERVER (
  44. HOST 'sql-server',
  45. PORT 1433,
  46. DATABASE test_50,
  47. USER '${arg.default-sql-server-user}',
  48. PASSWORD = SECRET sql_server_pass
  49. );
  50. ! CREATE SOURCE table_text_source
  51. FROM SQL SERVER CONNECTION sql_server_test_50_connection
  52. FOR TABLES (dbo.table_text);
  53. contains: SQL SERVER source validation: column dbo.table_text.bad of type text is not supported
  54. > CREATE SOURCE table_text_source
  55. FROM SQL SERVER CONNECTION sql_server_test_50_connection (
  56. EXCLUDE COLUMNS (dbo.table_text.bad)
  57. )
  58. FOR TABLES (dbo.table_text);
  59. > SHOW COLUMNS FROM table_text;
  60. good true "character varying" ""
  61. # Wait until snapshot has emitted stats and then insert a new row
  62. # to force LSN in MS SQL to progress.
  63. > SELECT s.name, ss.snapshot_records_known = ss.snapshot_records_staged
  64. FROM mz_internal.mz_source_statistics ss JOIN mz_sources s using (id)
  65. WHERE s.name = 'table_text_source' AND ss.snapshot_records_staged > 0;
  66. table_text_source true
  67. $ sql-server-execute name=sql-server
  68. INSERT INTO dummy VALUES (1);
  69. > SELECT * FROM table_text;
  70. "i work"
  71. "maybe me"
  72. > DROP SOURCE table_text_source CASCADE;
  73. ! CREATE SOURCE table_image_source
  74. FROM SQL SERVER CONNECTION sql_server_test_50_connection
  75. FOR TABLES (dbo.table_image);
  76. contains: SQL SERVER source validation: column dbo.table_image.bad of type image is not supported
  77. ! CREATE SOURCE table_geography_source
  78. FROM SQL SERVER CONNECTION sql_server_test_50_connection
  79. FOR TABLES (dbo.table_geography);
  80. contains: SQL SERVER source validation: column dbo.table_geography.bad of type geography is not supported
  81. ! CREATE SOURCE table_geometry_source
  82. FROM SQL SERVER CONNECTION sql_server_test_50_connection
  83. FOR TABLES (dbo.table_geometry);
  84. contains: SQL SERVER source validation: column dbo.table_geometry.bad of type geometry is not supported
  85. ! CREATE SOURCE table_varchar_max_source
  86. FROM SQL SERVER CONNECTION sql_server_test_50_connection
  87. FOR TABLES (dbo.table_varchar_max);
  88. contains: SQL SERVER source validation: column dbo.table_varchar_max.bad of type varchar is not supported
  89. ## same tests for source tables
  90. # Creating a source with no subsources should succeed
  91. > CREATE SOURCE ms_src
  92. FROM SQL SERVER CONNECTION sql_server_test_50_connection;
  93. ! CREATE TABLE table_text
  94. FROM SOURCE ms_src (REFERENCE dbo.table_text);
  95. contains: SQL SERVER source validation: column dbo.table_text.bad of type text is not supported
  96. > CREATE TABLE table_text
  97. FROM SOURCE ms_src (REFERENCE dbo.table_text)
  98. WITH (
  99. EXCLUDE COLUMNS (bad)
  100. );
  101. # Wait until snapshot has emitted stats and then insert a new row
  102. # to force LSN in MS SQL to progress.
  103. > SELECT s.name, ss.snapshot_records_known = ss.snapshot_records_staged
  104. FROM mz_internal.mz_source_statistics ss JOIN mz_sources s using (id)
  105. WHERE s.name = 'ms_src' AND ss.snapshot_records_staged > 0;
  106. ms_src true
  107. $ sql-server-execute name=sql-server
  108. INSERT INTO dummy VALUES (1);
  109. > SHOW COLUMNS FROM table_text;
  110. good true "character varying" ""
  111. > SELECT * FROM table_text;
  112. "i work"
  113. "maybe me"
  114. ! CREATE TABLE table_image
  115. FROM SOURCE ms_src (REFERENCE dbo.table_image);
  116. contains: SQL SERVER source validation: column dbo.table_image.bad of type image is not supported
  117. ! CREATE TABLE table_geography
  118. FROM SOURCE ms_src (REFERENCE dbo.table_geography);
  119. contains: SQL SERVER source validation: column dbo.table_geography.bad of type geography is not supported
  120. ! CREATE TABLE table_geometry
  121. FROM SOURCE ms_src (REFERENCE dbo.table_geometry);
  122. contains: SQL SERVER source validation: column dbo.table_geometry.bad of type geometry is not supported
  123. ! CREATE TABLE table_varchar_max
  124. FROM SOURCE ms_src (REFERENCE dbo.table_varchar_max);
  125. contains: SQL SERVER source validation: column dbo.table_varchar_max.bad of type varchar is not supported
  126. > DROP SOURCE ms_src CASCADE;