MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestETLCommentedQueries

Function TestETLCommentedQueries

server/etl_patterns_test.go:15–123  ·  view source on GitHub ↗

TestETLQueryPatterns tests query patterns commonly used by ETL tools like Fivetran. These patterns include: - Queries with leading comments (e.g., /* sync_id:abc123 */) - Schema and table creation/management - Metadata queries against information_schema and pg_catalog - Transaction handling - Data m

(t *testing.T)

Source from the content-addressed store, hash-verified

13// - Data manipulation (INSERT, UPDATE, DELETE)
14
15func TestETLCommentedQueries(t *testing.T) {
16 // ETL tools often prefix queries with tracking comments
17 tests := []struct {
18 name string
19 query string
20 returnsResults bool
21 commandType string
22 }{
23 // Schema operations with comments
24 {
25 name: "create schema with comment",
26 query: "/* sync_id:abc123 */ CREATE SCHEMA IF NOT EXISTS etl_destination",
27 returnsResults: false,
28 commandType: "CREATE SCHEMA",
29 },
30 {
31 name: "drop schema with comment",
32 query: "/* sync_id:abc123 */ DROP SCHEMA IF EXISTS etl_destination CASCADE",
33 returnsResults: false,
34 commandType: "DROP SCHEMA",
35 },
36
37 // Table operations with comments
38 {
39 name: "create table with comment",
40 query: "/* sync_id:abc123 */ CREATE TABLE etl_destination.users (id INTEGER, name VARCHAR, created_at TIMESTAMP)",
41 returnsResults: false,
42 commandType: "CREATE TABLE",
43 },
44 {
45 name: "drop table with comment",
46 query: "/* sync_id:abc123 */ DROP TABLE IF EXISTS etl_destination.users",
47 returnsResults: false,
48 commandType: "DROP TABLE",
49 },
50
51 // Select queries with comments (metadata inspection)
52 {
53 name: "select with comment",
54 query: "/* sync_id:abc123 */ SELECT * FROM information_schema.tables WHERE table_schema = 'etl_destination'",
55 returnsResults: true,
56 commandType: "SELECT",
57 },
58 {
59 name: "select columns with comment",
60 query: "/* sync_id:abc123 */ SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'users'",
61 returnsResults: true,
62 commandType: "SELECT",
63 },
64
65 // Data operations with comments
66 {
67 name: "insert with comment",
68 query: "/* sync_id:abc123 */ INSERT INTO etl_destination.users (id, name) VALUES (1, 'test')",
69 returnsResults: false,
70 commandType: "INSERT",
71 },
72 {

Callers

nothing calls this directly

Calls 3

getCommandTypeMethod · 0.95
queryReturnsResultsFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected