Accessing Arrays - placement of index
See original GitHub issueDocumentation feedback
- Page title: Selecting data
- Page URL: https://crate.io/docs/crate/reference/en/latest/general/dql/selects.html
- Source: https://github.com/crate/crate/blob/master/docs/general/dql/selects.rst
From the documentation it is unclear how to correctly access arrays within objects. The example has the index right after the identifier, but it is not clear if information is an object or array:
select name, information[1]['population'] as population from locations
... where information['population'] is not null
... order by name;
Putting the index first look unintuitive
CREATE TABLE test (a OBJECT);
insert into a values({ id = 1, name = 'foo', tags = ['apple', 'banana', 'pear'], size = 3.1415, valid = true });
SELECT a FROM test limit 100;
-- SELECT OK, 1 row in set (0.005 sec)
SELECT a[1]['tags'] FROM test limit 100;
-- SELECT a[1]['tags'] FROM test limit 100; --> apple
SELECT a['tags'][1] FROM test LIMIT 100;
-- SQLActionException[UnsupportedFeatureException: Nested array access is not supported]
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Indexing into an Array | Introduction to Computer Science
Arrays are ordered lists. Each element can be accessed by its index (its position in the list). The first element in an array...
Read more >How to access the elements of an array by index number in C++
We can easily access the elements of a given array by referring to their index number. Remember that in C++, the first element...
Read more >Array Indexing - Problem Solving with Python
Elements in NumPy arrays can be accessed by indexing. Indexing is an operation that pulls out a select set of values from an...
Read more >Find the index of an array element in Java - GeeksforGeeks
An element in an array of N integers can be searched using the below-mentioned ... Index position of 5 is: 0 Index position...
Read more >Array Indexing - MATLAB & Simulink - MathWorks
Every variable in MATLAB® is an array that can hold many numbers. When you want to access selected elements of an array, use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mechanomi I think this is something where we can also look into changing the behavior or support both versions.
This is indeed rather unintuitive:
With an explicit cast it would work:
@mechanomi
Looks good to me.
Though I think there is a small typing error
Lucine
instead ofLucene
in the Limitations section … can’t find the pr