{"record":{"id":"ecb6092f20ebc599","repo":"risingwavelabs/risingwave","slug":"mysql-query-function-is-not-supported-in-streaming","errorCode":null,"errorMessage":"mysql_query function is not supported in streaming mode","messagePattern":"mysql_query function is not supported in streaming mode","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/logical_mysql_query.rs","lineNumber":107,"sourceCode":"    fn predicate_pushdown(\n        &self,\n        predicate: Condition,\n        _ctx: &mut PredicatePushdownContext,\n    ) -> LogicalPlanRef {\n        // No pushdown.\n        LogicalFilter::create(self.clone().into(), predicate)\n    }\n}\n\nimpl ToBatch for LogicalMySqlQuery {\n    fn to_batch(&self) -> Result<BatchPlanRef> {\n        Ok(BatchMySqlQuery::new(self.core.clone()).into())\n    }\n}\n\nimpl ToStream for LogicalMySqlQuery {\n    fn to_stream(&self, _ctx: &mut ToStreamContext) -> Result<StreamPlanRef> {\n        bail!(\"mysql_query function is not supported in streaming mode\")\n    }\n\n    fn logical_rewrite_for_stream(\n        &self,\n        _ctx: &mut RewriteStreamContext,\n    ) -> Result<(PlanRef, ColIndexMapping)> {\n        bail!(\"mysql_query function is not supported in streaming mode\")\n    }\n}\n","sourceCodeStart":89,"sourceCodeEnd":117,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/logical_mysql_query.rs#L89-L117","documentation":"LogicalMySqlQuery represents a query executed via the mysql_query table function, which can only be evaluated in batch mode by pushing the query to the external MySQL source. Streaming execution (materialized views, sources) cannot continuously evaluate such a query, so to_stream deliberately returns an error.","triggerScenarios":"Creating a materialized view, source, or any streaming plan that contains a mysql_query(...) table function call, causing the stream optimizer to call to_stream on LogicalMySqlQuery.","commonSituations":"A user runs CREATE MATERIALIZED VIEW AS SELECT * FROM mysql_query(...) expecting live replication of an external MySQL query; envs where teams assume mysql_query can act as a streaming source.","solutions":["Do not use mysql_query in materialized views or any streaming query; keep it in ad-hoc batch SELECT statements","Use RisingWave's MySQL CDC connector to ingest the table as a streaming source instead of querying per-request","Batch-query the data first and persist results to a table/MV via an ingestion pipeline that supports streaming","If periodic refresh is acceptable, schedule batch inserts into a table rather than an MV over mysql_query"],"exampleFix":"-- before (fails)\nCREATE MATERIALIZED VIEW mv AS SELECT * FROM mysql_query('conn_name', 'SELECT * FROM t');\n-- after: batch query only, or use CDC source\nSELECT * FROM mysql_query('conn_name', 'SELECT * FROM t');\n-- streaming alternative: MySQL CDC source + materialized view over the source","handlingStrategy":"validation","validationCode":"-- Pre-check that a definition does not use mysql_query before making it streaming\n-- inspect the SQL for the function, e.g. in application code:\n-- if /\\bmysql_query\\s*\\(/i.test(sql) rejectStreamingDefinition();","typeGuard":null,"tryCatchPattern":"// psql/driver catch\ntry {\n  await conn.query('CREATE MATERIALIZED VIEW mv AS SELECT * FROM mysql_query(...)');\n} catch (e) {\n  if (String(e.message).includes('mysql_query function is not supported in streaming mode')) {\n    // fall back to batch query or set up a CDC source\n  }\n  throw e;\n}","preventionTips":["Never use mysql_query in CREATE MATERIALIZED VIEW / INDEX or other streaming DDL","Use MySQL CDC connectors for streaming ingestion from MySQL","Reserve mysql_query for ad-hoc batch SELECTs","Review team SQL templates for external query functions before streaming jobs"],"tags":["rust","streaming","mysql","external-source"],"backgroundTag":"unsupported-operation","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}