Skip to content

[Compatibility]: CONCAT and CONCAT_WS reject JSON operands #28907

Closed as not planned
Closed as not planned

Description

@Ariznawlll

Problem

CONCAT and CONCAT_WS reject JSON operands that MySQL stringifies. This prevents direct queries as well as View/CTAS and prepared SQL over JSON columns.

Reproduction

drop database if exists concat_json_repro;
create database concat_json_repro;
use concat_json_repro;

create table src(id int primary key,js json,v varchar(20));
insert into src values
  (1,'{"b":2,"a":1}','Aé中a'),
  (2,'null',''),
  (3,null,null);

select id,
       concat('',js),
       concat(js,''),
       concat_ws('|','x',js,'y'),
       concat_ws('|',js,v)
from src order by id;

create view v_json as
select id,concat_ws('|','x',js,'y') c from src;

prepare p from
  'select id,concat_ws(''|'',''x'',js,''y'') from src order by id';
execute p;

MatrixOne result

  • Two-argument CONCAT returns invalid argument function concat, bad value [CHAR JSON].
  • CONCAT_WS returns invalid argument function concat_ws, bad value [VARCHAR VARCHAR JSON VARCHAR].
  • View creation and prepared compilation are rejected on the same JSON operand.

MySQL 8.0.45 result

MySQL renders the JSON value using its normal JSON text representation:

{"a": 1, "b": 2}
null
SQL NULL

CONCAT preserves SQL NULL. CONCAT_WS includes the JSON literal null but skips SQL NULL, matching its ordinary NULL rules. View, CTAS, and prepared execution retain those values.

Control and scope

Explicit CAST(js AS CHAR) makes both CONCAT and CONCAT_WS work in MatrixOne and produces the same JSON text as MySQL. Canonical object output, JSON null, SQL NULL, mixed JSON/VARCHAR inputs, View/CTAS, and prepared SQL are covered. Three independent executions produced identical results on each database.

Code location

The builtInConcatCheck and concatWsCheck argument conversion paths use the generic implicit cast to VARCHAR; JSON has no accepted implicit conversion there even though explicit JSON-to-character conversion already supplies the required representation.

Environment

  • MatrixOne: official main commit 0c3a04f390adaf6281fd592a49778ea5b1155e67
  • MySQL control: 8.0.45
  • Local single-node MatrixOne deployment

Activity

  1. added this to the MO-202609 milestone on Sep 15, 2026
  2. added theissue type on Sep 15, 2026
  3. Ariznawlll commented on Sep 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    Duplicate of #28905. This issue was created a second time accidentally; please track JSON operands in CONCAT/CONCAT_WS in #28905.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/compatibilitykind/bug

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions