question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems comparing empty tuples/arrays

See original GitHub issue
  • EdgeDB Version: 1-beta1

I’ve been experimenting with DISTINCT and discovered a few things:

  1. When different types are passed to distinct, it leaks implementation details (UNION) in error:
edgedb> select distinct {1, "1"};
ERROR: QueryError: operator 'UNION' cannot be applied to operands of type 'std::int64' and 'std::str'
  Hint: Consider using an explicit type cast or a conversion function.
  1. It has some problems comparing empty tuples:
edgedb> select distinct {(), (), ()};
{(), (), ()}

Note: this doesn’t work with empty arrays, compiler makes me annotate 2nd argument.

Trying to figure out what’s going on, I tried comparing empty tuples manually. This is what I’ve got:

edgedb> select <tuple<str>>{} = ("",);
{}
edgedb> select <array<str>>{} = ["",];
{}

Not sure if these are issues that should be fixed or I misunderstood something.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
1st1commented, Mar 8, 2021

@elprans

ERROR: QueryError: operator ‘UNION’ cannot be applied to operands of type ‘std::int64’ and ‘std::str’

This is not about DISTINCT, you cannot UNION two incompatible types, and the set literal { … } is a syntax sugar over the UNION operator.

Maybe we should improve this error message. The fact that {x, y} is compiled to x UNION y isn’t an obvious thing, especially to beginners. The error message we raise right now is just hard to interpret.

0reactions
1st1commented, Oct 22, 2021

@vpetrovykh please see if you can improve the error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to compare numpy arrays of tuples? - Stack Overflow
However if you compare with a_comp = np. array((-1,-1), dtype="i,i") you get the exact behavior you are expecting!
Read more >
Python Tuples - GeeksforGeeks
Initial empty Tuple: () Tuple with the use of String: ('Geeks', ... left-hand side should be equal to a number of values in...
Read more >
Python Tuple vs List - Comparison Between Lists and Tuples
This article explains the similarities and key differences between tuple vs list in python and it's importance while solving questions ...
Read more >
Python: Check if Tuple is Empty - STechies
How to Check Empty Tuple in Python? · Using the not operator · Using the len() function · Comparing with another empty tuple....
Read more >
Nim Tutorial (Part I) - Nim Programming Language
For comparing the performance with unsafe languages like C, use the -d:danger ... Other useful iterators for collections (like arrays and sequences) are....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found