Giter Site home page Giter Site logo

Comments (4)

tomatolog avatar tomatolog commented on May 27, 2024 1

fixed at e0fd6c0

Now filter select * from idx where j.color in ( 'blue' ) should work the exactly as select *, j.color in ( 'blue' ) as cnd from ifx where cnd=1
Prior to the fix filter IN ( string list ) by json attribute assumes that json.field as always a single string now it should work properly with the multiple kinds of json.field

from manticoresearch.

sanikolaev avatar sanikolaev commented on May 27, 2024

but there's no case for json field with array of strings

Right. What was done in 88e7179 changes the behaviour for non-arrays. Moreover the behaviour for arrays and scalars is different even when going the ... as cond way:

mysql> drop table if exists t; CREATE TABLE t (j json); INSERT INTO t(j) values ('{"a": [1,2]}'),('{"a": 1}'); SELECT * FROM t WHERE j.a IN (1); select *, ANY(x=1 FOR x IN j.a) cond from t;
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.02 sec)

--------------
CREATE TABLE t (j json)
--------------

Query OK, 0 rows affected (0.03 sec)

--------------
INSERT INTO t(j) values ('{"a": [1,2]}'),('{"a": 1}')
--------------

Query OK, 2 rows affected (0.00 sec)

--------------
SELECT * FROM t WHERE j.a IN (1)
--------------

+---------------------+---------+
| id                  | j       |
+---------------------+---------+
| 1515687300166582363 | {"a":1} |
+---------------------+---------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---

--------------
select *, ANY(x=1 FOR x IN j.a) cond from t
--------------

+---------------------+-------------+------+
| id                  | j           | cond |
+---------------------+-------------+------+
| 1515687300166582362 | {"a":[1,2]} |    1 |
| 1515687300166582363 | {"a":1}     |    0 |
+---------------------+-------------+------+
2 rows in set (0.00 sec)
--- 2 out of 2 results in 0ms ---

So I'm not sure it's a bug since WHERE j.a IN (...) is a little ambiguous while using FOR makes it more clear. WHERE ANY/ALL(j.a) IN (...) would make it more clear too, so perhaps this is the syntax which makes sense in the context of this task and comparison with arrays.

from manticoresearch.

sashahohloma avatar sashahohloma commented on May 27, 2024

OK, thank you.

This behavior seemed like a bug because

  1. Example table of original issue contains JSON column with array attribute
  2. Query with WHERE json.array IN (...) does not return an error

Query with WHERE ANY/ALL(json.array) IN (...) sounds great, because virtual conditional column cannot be included in HTTP search request

from manticoresearch.

tomatolog avatar tomatolog commented on May 27, 2024

related to #778

from manticoresearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.