MCPcopy Create free account
hub / github.com/apecloud/myduckserver / TestFuncReplacement

Function TestFuncReplacement

pgserver/in_place_handler_test.go:20–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestFuncReplacement(t *testing.T) {
21 tests := []struct {
22 name string
23 executions []FuncReplacementExecution
24 }{
25 // Get Postgresql Configuration
26 {
27 name: "Test Metabase query on Postgresql Configuration 1",
28 executions: []FuncReplacementExecution{
29 {
30 // The testing target is 'PG_CATALOG.PG_GET_INDEXDEF' and 'INFORMATION_SCHEMA._PG_EXPANDARRAY'
31 SQL: `SELECT
32 "tmp"."table-schema", "tmp"."table-name",
33 TRIM(BOTH '"' FROM PG_CATALOG.PG_GET_INDEXDEF("tmp"."ci_oid", "tmp"."pos", FALSE)) AS "field-name"
34FROM (SELECT
35 "n"."nspname" AS "table-schema",
36 "ct"."relname" AS "table-name",
37 "ci"."oid" AS "ci_oid",
38 (INFORMATION_SCHEMA._PG_EXPANDARRAY("i"."indkey"))."n" AS "pos"
39 FROM "pg_catalog"."pg_class" AS "ct"
40 INNER JOIN "pg_catalog"."pg_namespace" AS "n" ON "ct"."relnamespace" = "n"."oid"
41 INNER JOIN "pg_catalog"."pg_index" AS "i" ON "ct"."oid" = "i"."indrelid"
42 INNER JOIN "pg_catalog"."pg_class" AS "ci" ON "ci"."oid" = "i"."indexrelid"
43 WHERE (PG_CATALOG.PG_GET_EXPR("i"."indpred", "i"."indrelid") IS NULL)
44 AND n.nspname !~ '^information_schema|catalog_history|pg_') AS "tmp"
45WHERE "tmp"."pos" = 1`,
46 // TODO(sean): There's no data currently, we just check the query is executed without error
47 Expected: [][]string{},
48 WantErr: false,
49 },
50 },
51 },
52 {
53 name: "Test Metabase query on Postgresql Configuration 2",
54 executions: []FuncReplacementExecution{
55 {
56 // The testing target is 'pg_class'::RegClass
57 SQL: `SELECT
58 n.nspname AS schema,
59 c.relname AS name,
60 CASE c.relkind
61 WHEN 'r' THEN 'TABLE'
62 WHEN 'p' THEN 'PARTITIONED TABLE'
63 WHEN 'v' THEN 'VIEW'
64 WHEN 'f' THEN 'FOREIGN TABLE'
65 WHEN 'm' THEN 'MATERIALIZED VIEW'
66 ELSE NULL
67 END AS type,
68 d.description AS description,
69 stat.n_live_tup AS estimated_row_count
70FROM pg_catalog.pg_class AS c
71 INNER JOIN pg_catalog.pg_namespace AS n ON c.relnamespace = n.oid
72 LEFT JOIN pg_catalog.pg_description AS d ON ((c.oid = d.objoid)
73 AND (d.objsubid = 1))
74 AND (d.classoid = 'pg_class'::RegClass)
75 LEFT JOIN pg_stat_user_tables AS stat ON (n.nspname = stat.schemaname)
76 AND (c.relname = stat.relname)
77WHERE ((((c.relnamespace = n.oid) AND (n.nspname !~ 'information_schema'))

Callers

nothing calls this directly

Calls 9

CreateTestDirFunction · 0.92
NewTestEnvFunction · 0.92
StartDuckSqlServerFunction · 0.92
StopDuckSqlServerFunction · 0.92
CloseMethod · 0.65
RunMethod · 0.45
ConnectMethod · 0.45
NextMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected