>>>pipeline_explain.txt
=== FunctionCalls
ID:          default_catalog.default_database.FunctionCalls
Type:        stream
Stage:       flink
Primary key: -
Timestamp:   -
Row count:   ~1e8
---
Schema:
 - searchResult: DOUBLE NOT NULL
 - format: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL
Inputs:
 - default_catalog.default_database.Product
Annotations:
 - stream-root: Product
Plan:
LogicalProject(searchResult=[text_search('garden gnome', $3, $1)], format=[format('Go buy: %s in %s with id=%s', $1, $3, CAST($0):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL)])
  LogicalTableScan(table=[[default_catalog, default_database, Product]])
SQL:
CREATE VIEW `FunctionCalls` AS  SELECT text_search('garden gnome', category, name) AS searchResult,
                        format('Go buy: %s in %s with id=%s', name, category, CAST(productid AS STRING)) AS format
    FROM Product;

=== Product
ID:          default_catalog.default_database.Product
Type:        stream
Stage:       flink
Primary key: productid, name, description, category
Timestamp:   _ingest_time
Row count:   ~1e8
---
Schema:
 - productid: BIGINT NOT NULL
 - name: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL
 - description: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL
 - category: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL
 - _ingest_time: TIMESTAMP_LTZ(3) *ROWTIME* NOT NULL
Inputs:
 - default_catalog.default_database.Product__base
Annotations:
 - stream-root: Product
Plan:
LogicalWatermarkAssigner(rowtime=[_ingest_time], watermark=[-($4, 1:INTERVAL SECOND)])
  LogicalTableScan(table=[[default_catalog, default_database, Product]])
SQL:
CREATE TEMPORARY TABLE `Product__schema` (
  `productid` BIGINT NOT NULL,
  `name` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `description` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `category` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `_ingest_time` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL
)
WITH (
  'connector' = 'datagen'
);
CREATE TABLE `Product` (
  PRIMARY KEY (`productid`, `name`, `description`, `category`) NOT ENFORCED,
  WATERMARK FOR `_ingest_time` AS `_ingest_time` - INTERVAL '0.001' SECOND
)
WITH (
  'format' = 'flexible-json',
  'path' = 'file:/mock',
  'source.monitor-interval' = '10 sec',
  'connector' = 'filesystem'
)
LIKE `Product__schema`
>>>flink-sql-no-functions.sql
CREATE TEMPORARY TABLE `Product__schema` (
  `productid` BIGINT NOT NULL,
  `name` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `description` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `category` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `_ingest_time` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL
)
WITH (
  'connector' = 'datagen'
);
CREATE TABLE `Product` (
  PRIMARY KEY (`productid`, `name`, `description`, `category`) NOT ENFORCED,
  WATERMARK FOR `_ingest_time` AS `_ingest_time` - INTERVAL '0.001' SECOND
)
WITH (
  'format' = 'flexible-json',
  'path' = 'file:/mock',
  'source.monitor-interval' = '10 sec',
  'connector' = 'filesystem'
)
LIKE `Product__schema`;
CREATE VIEW `FunctionCalls`
AS
SELECT `text_search`('garden gnome', `category`, `name`) AS `searchResult`, `format`('Go buy: %s in %s with id=%s', `name`, `category`, CAST(`productid` AS STRING)) AS `format`
FROM `Product`;
CREATE TABLE `FunctionCalls_1` (
  `searchResult` DOUBLE NOT NULL,
  `format` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `__pk_hash` CHAR(32) CHARACTER SET `UTF-16LE`,
  PRIMARY KEY (`__pk_hash`) NOT ENFORCED
)
WITH (
  'connector' = 'jdbc-sqrl',
  'driver' = 'org.postgresql.Driver',
  'password' = '${POSTGRES_PASSWORD}',
  'sink.on-conflict.action' = 'IGNORE',
  'table-name' = 'FunctionCalls_1',
  'url' = 'jdbc:postgresql://${POSTGRES_AUTHORITY}',
  'username' = '${POSTGRES_USERNAME}'
);
CREATE TABLE `Product_2` (
  `productid` BIGINT NOT NULL,
  `name` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `description` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `category` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,
  `_ingest_time` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL,
  PRIMARY KEY (`productid`, `name`, `description`, `category`) NOT ENFORCED
)
WITH (
  'connector' = 'jdbc-sqrl',
  'driver' = 'org.postgresql.Driver',
  'password' = '${POSTGRES_PASSWORD}',
  'sink.on-conflict.action' = 'IGNORE',
  'table-name' = 'Product_2',
  'url' = 'jdbc:postgresql://${POSTGRES_AUTHORITY}',
  'username' = '${POSTGRES_USERNAME}'
);
EXECUTE STATEMENT SET BEGIN
INSERT INTO `default_catalog`.`default_database`.`FunctionCalls_1`
SELECT `searchResult`, `format`, `hash_columns`(`searchResult`, `format`) AS `__pk_hash`
 FROM `default_catalog`.`default_database`.`FunctionCalls`
;
INSERT INTO `default_catalog`.`default_database`.`Product_2`
 SELECT *
  FROM `default_catalog`.`default_database`.`Product`
 ;
 END
>>>kafka.json
{
  "topics" : [ ],
  "testRunnerTopics" : [ ]
}
>>>postgres.json
{
  "statements" : [
    {
      "name" : "FunctionCalls_1",
      "type" : "TABLE",
      "sql" : "CREATE TABLE IF NOT EXISTS \"FunctionCalls_1\" (\"searchResult\" DOUBLE PRECISION NOT NULL, \"format\" TEXT NOT NULL, \"__pk_hash\" TEXT, PRIMARY KEY (\"__pk_hash\"))",
      "fields" : [
        {
          "name" : "searchResult",
          "type" : "DOUBLE PRECISION",
          "nullable" : false
        },
        {
          "name" : "format",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "__pk_hash",
          "type" : "TEXT",
          "nullable" : true
        }
      ],
      "primaryKey" : [
        "__pk_hash"
      ],
      "partitionKey" : [ ],
      "partitionType" : "NONE",
      "numPartitions" : 0,
      "ttl" : 0.0
    },
    {
      "name" : "Product_2",
      "type" : "TABLE",
      "sql" : "CREATE TABLE IF NOT EXISTS \"Product_2\" (\"productid\" BIGINT NOT NULL, \"name\" TEXT NOT NULL, \"description\" TEXT NOT NULL, \"category\" TEXT NOT NULL, \"_ingest_time\" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY (\"productid\",\"name\",\"description\",\"category\"))",
      "fields" : [
        {
          "name" : "productid",
          "type" : "BIGINT",
          "nullable" : false
        },
        {
          "name" : "name",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "description",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "category",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "_ingest_time",
          "type" : "TIMESTAMP WITH TIME ZONE",
          "nullable" : false
        }
      ],
      "primaryKey" : [
        "productid",
        "name",
        "description",
        "category"
      ],
      "partitionKey" : [ ],
      "partitionType" : "NONE",
      "numPartitions" : 0,
      "ttl" : 0.0
    },
    {
      "name" : "FunctionCalls",
      "type" : "VIEW",
      "sql" : "CREATE OR REPLACE VIEW \"FunctionCalls\"(\"searchResult\", \"format\") AS SELECT \"searchResult\", \"format\"\nFROM \"FunctionCalls_1\"",
      "fields" : [
        {
          "name" : "searchResult",
          "type" : "DOUBLE PRECISION",
          "nullable" : false
        },
        {
          "name" : "format",
          "type" : "TEXT",
          "nullable" : false
        }
      ]
    },
    {
      "name" : "Product",
      "type" : "VIEW",
      "sql" : "CREATE OR REPLACE VIEW \"Product\"(\"productid\", \"name\", \"description\", \"category\", \"_ingest_time\") AS SELECT *\nFROM \"Product_2\"",
      "fields" : [
        {
          "name" : "productid",
          "type" : "BIGINT",
          "nullable" : false
        },
        {
          "name" : "name",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "description",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "category",
          "type" : "TEXT",
          "nullable" : false
        },
        {
          "name" : "_ingest_time",
          "type" : "TIMESTAMP WITH TIME ZONE",
          "nullable" : false
        }
      ]
    }
  ]
}
>>>vertx.json
{
  "models" : {
    "v1" : {
      "queries" : [
        {
          "type" : "args",
          "parentType" : "Query",
          "fieldName" : "FunctionCalls",
          "exec" : {
            "arguments" : [
              {
                "type" : "variable",
                "path" : "limit"
              },
              {
                "type" : "variable",
                "path" : "offset"
              }
            ],
            "query" : {
              "type" : "SqlQuery",
              "sql" : "SELECT \"searchResult\", \"format\"\nFROM \"FunctionCalls_1\"",
              "parameters" : [ ],
              "pagination" : "LIMIT_AND_OFFSET",
              "cacheDurationMs" : 0,
              "database" : "POSTGRES"
            }
          }
        },
        {
          "type" : "args",
          "parentType" : "Query",
          "fieldName" : "Product",
          "exec" : {
            "arguments" : [
              {
                "type" : "variable",
                "path" : "limit"
              },
              {
                "type" : "variable",
                "path" : "offset"
              }
            ],
            "query" : {
              "type" : "SqlQuery",
              "sql" : "SELECT *\nFROM \"Product_2\"",
              "parameters" : [ ],
              "pagination" : "LIMIT_AND_OFFSET",
              "cacheDurationMs" : 0,
              "database" : "POSTGRES"
            }
          }
        }
      ],
      "mutations" : [ ],
      "subscriptions" : [ ],
      "operations" : [
        {
          "function" : {
            "name" : "GetFunctionCalls",
            "parameters" : {
              "type" : "object",
              "properties" : {
                "offset" : {
                  "type" : "integer"
                },
                "limit" : {
                  "type" : "integer"
                }
              },
              "required" : [ ]
            }
          },
          "format" : "JSON",
          "apiQuery" : {
            "query" : "query FunctionCalls($limit: Int = 10, $offset: Int = 0) {\nFunctionCalls(limit: $limit, offset: $offset) {\nsearchResult\nformat\n}\n\n}",
            "queryName" : "FunctionCalls",
            "operationType" : "QUERY"
          },
          "mcpMethod" : "TOOL",
          "restMethod" : "GET",
          "uriTemplate" : "queries/FunctionCalls{?offset,limit}"
        },
        {
          "function" : {
            "name" : "GetProduct",
            "parameters" : {
              "type" : "object",
              "properties" : {
                "offset" : {
                  "type" : "integer"
                },
                "limit" : {
                  "type" : "integer"
                }
              },
              "required" : [ ]
            }
          },
          "format" : "JSON",
          "apiQuery" : {
            "query" : "query Product($limit: Int = 10, $offset: Int = 0) {\nProduct(limit: $limit, offset: $offset) {\nproductid\nname\ndescription\ncategory\n}\n\n}",
            "queryName" : "Product",
            "operationType" : "QUERY"
          },
          "mcpMethod" : "TOOL",
          "restMethod" : "GET",
          "uriTemplate" : "queries/Product{?offset,limit}"
        }
      ],
      "schema" : {
        "type" : "string",
        "schema" : "\"An RFC-3339 compliant Full Date Scalar\"\nscalar Date\n\n\"A DateTime scalar that handles both full RFC3339 and shorter timestamp formats\"\nscalar DateTime\n\ntype FunctionCalls {\n  searchResult: Float!\n  format: String!\n}\n\n\"A JSON scalar\"\nscalar JSON\n\n\"24-hour clock time value string in the format `hh:mm:ss` or `hh:mm:ss.sss`.\"\nscalar LocalTime\n\n\"A 64-bit signed integer\"\nscalar Long\n\ntype Product {\n  productid: Long!\n  name: String!\n  description: String!\n  category: String!\n}\n\ntype Query {\n  FunctionCalls(limit: Int = 10, offset: Int = 0): [FunctionCalls!]\n  Product(limit: Int = 10, offset: Int = 0): [Product!]\n}\n\nenum _McpMethodType {\n  NONE\n  TOOL\n  RESOURCE\n}\n\nenum _RestMethodType {\n  NONE\n  GET\n  POST\n}\n\ndirective @api(mcp: _McpMethodType, rest: _RestMethodType, uri: String) on QUERY | MUTATION | FIELD_DEFINITION\n"
      }
    }
  }
}
