View Issue Details [ Jump to Notes ] [ Issue History ] [ Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002452Sphinxgeneralpublic2016-04-05 15:492016-04-07 12:55
ReporterOrdos 
Assigned Tojoric 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
Product Version2.2.10-release 
Target Version2.2.11-releaseFixed in Version2.2.11-release 
Summary0002452: group by aliased JSON array
DescriptionИндексируем xml:

<?xml version="1.0" encoding="utf-8"?>
<sphinx:docset xmlns:sphinx="http://sphinxsearch.com/"> [^]
  <sphinx:document id="1">
    <name>One</name>
    <data_json>{"a":[1],"b":[1,2,3,4]}</data_json>
  </sphinx:document>
  <sphinx:document id="2">
    <name>Two</name>
    <data_json>{"a":[1,2],"b":[1,2,4]}</data_json>
  </sphinx:document>
  <sphinx:document id="3">
    <name>Three</name>
    <data_json>{"a":[1,2,3],"b":[1,4]}</data_json>
  </sphinx:document>
</sphinx:docset>



Если группируемся по data_json.a и data_json.b - Всё корректно работает:

mysql> select groupby(),count(*) from test group by data_json.a;
+-----------+----------+
| groupby() | count(*) |
+-----------+----------+
| 1 | 3 |
| 2 | 2 |
| 3 | 1 |
+-----------+----------+
3 rows in set (0.03 sec)

mysql> select groupby(),count(*) from test group by data_json.b;
+-----------+----------+
| groupby() | count(*) |
+-----------+----------+
| 4 | 3 |
| 3 | 1 |
| 2 | 2 |
| 1 | 3 |
+-----------+----------+
4 rows in set (0.01 sec)



А если для data_json.a и data_json.b сделать алиасы и попробовать сгруппироваться по ним, то groupby() начинает возвращать непонятные цифры.

mysql> select groupby(),count(*),data_json.a a from test group by a;
+-------------+----------+---------+
| groupby() | count(*) | a |
+-------------+----------+---------+
| 25769803785 | 1 | [1] |
| 25769803824 | 1 | [1,2] |
| 25769803863 | 1 | [1,2,3] |
+-------------+----------+---------+
3 rows in set (0.01 sec)

mysql> select groupby(),count(*),data_json.b b from test group by b;
+-------------+----------+-----------+
| groupby() | count(*) | b |
+-------------+----------+-----------+
| 25769803793 | 1 | [1,2,3,4] |
| 25769803836 | 1 | [1,2,4] |
| 25769803879 | 1 | [1,4] |
+-------------+----------+-----------+
3 rows in set (0.02 sec)

Возможно будет лучше либо сделать одинаковое поведение, либо выводить ошибку о некорректном запросе.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007795)
joric (reporter)
2016-04-05 15:54

Assigned, will take a look.
(0007802)
joric (reporter)
2016-04-07 12:25
edited on: 2016-04-07 12:26

fixed in 8733d0a


- Issue History
Date Modified Username Field Change
2016-04-05 15:49 Ordos New Issue
2016-04-05 15:54 joric Note Added: 0007795
2016-04-05 15:54 joric Assigned To => joric
2016-04-05 15:54 joric Status new => assigned
2016-04-07 12:25 joric Note Added: 0007802
2016-04-07 12:25 joric Status assigned => closed
2016-04-07 12:25 joric Resolution open => fixed
2016-04-07 12:26 joric Summary Ошибка group by для json массива, который объявлен в select с алиасом. => group by aliased JSON array
2016-04-07 12:26 joric Note Edited: 0007802 View Revisions
2016-04-07 12:55 joric Product Version 2.3.1-beta => 2.2.10-release
2016-04-07 12:55 joric Fixed in Version => 2.2.11-release
2016-04-07 12:55 joric Target Version => 2.2.11-release


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker