3 ms·
I must say in this case Google does it right: https://cloud.google.com/spanner/docs/reference/standard-sql/arrays#accessing_array_elements https://cloud.google.
by kccqzy 4y ago
I must say in this case Google does it right: https://cloud.google.com/spanner/docs/reference/standard-sql/arrays#accessing_array_elements https://cloud.google.com/spanner/docs/reference/standard-sql...
In Google standard SQL, to access an array it is simply not allowed to put a number inside square brackets. You must specify which way you mean. So `SELECT some_numbers[OFFSET(1)], some_numbers[ORDINAL(1)]` is allowed but not `SELECT some_numbers[1]`.
- kergonath 4y agoThat sounds actually great to avoid any ambiguity. At the cost of a bit of verbosity, though.
- chii 4y agothat's actually good verbosity, because the intent is very clear using this method, and multiple people can read the code and unambiguously identify the intent without having to talk to the original author. This type of verbosity makes sense in a big organization where the left hand doesn't talk much to the right hand much, so communication naturally evolves to happen at the code level.
- kergonath 4y agoIndeed. I like for example using enum types to ensure that what’s actually passed is the expected value even though fundamentally the semantics do not need to be much more complicated than integer values. There could be the same thing with a distinction between offset and indices as two different integer numerical types to avoid any ambiguity.