Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rKysh-005POQ-Ls for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jan 2024 10:53:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rKysf-004ZjS-JL for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jan 2024 10:53:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rKysf-004ZjJ-9k for pgsql-hackers@lists.postgresql.org; Wed, 03 Jan 2024 10:53:49 +0000 Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rKysc-00DWOj-OZ for pgsql-hackers@postgresql.org; Wed, 03 Jan 2024 10:53:48 +0000 Received: by mail-vk1-xa2d.google.com with SMTP id 71dfb90a1353d-4b73a62f42eso577464e0c.1 for ; Wed, 03 Jan 2024 02:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704279226; x=1704884026; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ehbNF9q6LrD1P48PMitb0hEheGJCT7fWNnR1GLffTIw=; b=CU1bRvaApTNRGnTeCxlPHv6IsxC3kJFsYkbDXW5maI1lH3ZjSGPh54h5QMvaapVzLN vqcEb4G7XDDNpBdtCjSR4m65FoexxeWnpmU/uVoq5OchjGBEM5poLsqRZ2D7m43LkJLe L1rmGhgTdkDZMmxeQiaypZwIy+yYQ/eZ533wMU23rkOH/XuifzmA/IEDzyiosH/EIi/d 4aTuZOHX/gALyb7e+5EBa7Z2Uaz34G5kcMXwMoziQfShY7mwtdE6xHlVsODSvoYftmwD EHCzMuNTEC2Xd0F+9vB6+YNx5mFHWT/JNJ4z7MAgH8ZL53gAQl1u2eVXWaI7a3Soabf1 FuVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704279226; x=1704884026; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ehbNF9q6LrD1P48PMitb0hEheGJCT7fWNnR1GLffTIw=; b=wSHdK/Fs2M6OyDcRxDWEJhHHjz+TQzwzOonDL2Gp0RpxThX5RpFfmLN3FeZhhgbDFC opfqSxXEiS/zWhggeBC1MXSOkZDgSweGDra0sdR2g9Mi0I2kzoFWsIqrcei/adYz/h/7 heBhZTGhL55mc2fQf5TFg4exPNAtpNBoBaUUIZVEE2VhtkyhWNPlgrcuxbhsaxlDrKUc LXXE2xB0afwdk33mEDFQ6nyyVpbfPBoDlNg1WJr0vzMnEfA74FJHXm5XFTXPRKeF5HPr ta4PLvGlaC1h1f+W7r0H0q0faTOYzYiU5yeeU3z7sGEE7UzUQs2m51TvOmDVkyVv+uzk DZbA== X-Gm-Message-State: AOJu0Yxh5m9AMwVfPSEvHYrxXi3WOXfMEMOHDqUXA90XiJuNKxjhinMB Tugix2uJF7/zHxJukm5ag5EiIj0FOJstJBVSALE= X-Google-Smtp-Source: AGHT+IEe/5dm3KPnKUg8B8SGUcW5HLJztJT+hpQ3UZx/YY2RMPD85r/dZ7Ch+kutrF7rdyLxME6l9inLPBLE/zz1wtc= X-Received: by 2002:a05:6122:221f:b0:4b7:1507:5c07 with SMTP id bb31-20020a056122221f00b004b715075c07mr5073848vkb.9.1704279225850; Wed, 03 Jan 2024 02:53:45 -0800 (PST) MIME-Version: 1.0 References: <202312071051.cpxujwos4tlj@alvherre.pgsql> <20231208173014.2qycwc6kjqf6zlck@awork3.anarazel.de> In-Reply-To: From: jian he Date: Wed, 3 Jan 2024 18:53:34 +0800 Message-ID: Subject: Re: remaining sql/json patches To: Amit Langote Cc: Andres Freund , Alvaro Herrera , Erik Rijkers , Andrew Dunstan , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk some more minor issues: SELECT * FROM JSON_TABLE(jsonb '{"a":[123,2]}', '$' COLUMNS (item int[] PATH '$.a' error on error, foo text path '$' error on error)) bar; ERROR: JSON path expression in JSON_VALUE should return singleton scalar item the error message seems not so great, imho. since the JSON_TABLE doc entries didn't mention that JSON_TABLE actually transformed to json_value, json_query, json_exists. JSON_VALUE even though cannot specify KEEP | OMIT QUOTES. It might be a good idea to mention the default is to omit quotes in the doc. because JSON_TABLE actually transformed to json_value, json_query, json_exists. JSON_TABLE can specify quotes behavior freely. bother again, i kind of get what the function transformJsonTableChildPlan do, but adding more comments would make it easier to understand.... (json_query) + This function must return a JSON string, so if the path expression + returns multiple SQL/JSON items, you must wrap the result using the + WITH WRAPPER clause. If the wrapper is + UNCONDITIONAL, an array wrapper will always + be applied, even if the returned value is already a single JSON object + or an array, but if it is CONDITIONAL, it will not be + applied to a single array or object. UNCONDITIONAL + is the default. If the result is a scalar string, by default the value + returned will have surrounding quotes making it a valid JSON value, + which can be made explicit by specifying KEEP QUOTES. + Conversely, quotes can be omitted by specifying OMIT QUOTES. + The returned data_type has the same semantics + as for constructor functions like json_objectagg; + the default returned type is jsonb. + + Returns the result of applying the + path_expression to the + context_item using the + PASSING values. The + extracted value must be a single SQL/JSON scalar + item. For results that are objects or arrays, use the + json_query function instead. + The returned data_type has the same semantics + as for constructor functions like json_objectagg. + The default returned type is text. + The ON ERROR and ON EMPTY + clauses have similar semantics as mentioned in the description of + json_query. + + The returned data_type has the same semantics + as for constructor functions like json_objectagg. IMHO, the above description is not so good, since the function json_objectagg is listed in functions-aggregate.html, using Ctrl + F in the browser cannot find json_objectagg in functions-json.html. for json_query, maybe we can rephrase like: the RETURNING clause, which specifies the data type returned. It must be a type for which there is a cast from text to that type. By default, the jsonb type is returned. json_value: the RETURNING clause, which specifies the data type returned. It must be a type for which there is a cast from text to that type. By default, the text type is returned.