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.

Can we get these keys in the object column?

See original GitHub issue

Use case:

Only want get these keys of object

Feature description:

Something like this

SELECT DISTINCT obj.keys FROM t

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mfusseneggercommented, Nov 20, 2019

If I understand your question correctly the short answer is no. If they’re used in the WHERE clause they won’t utilize the index structures. But they can utilize the query cache in some cases. (So that sub-sequent executions are fast)

If your UDF will only be part of the select-list it usually has little impact on performance.

In your specific case we’d also load the value parts of the object, which of course has some costs. But we defer the value lookup as much as possible. So if the result set is already sufficiently reduced the impact will not matter.

But if you do for example a GROUP BY on the keys you’ve extracted than it will be slower than an optimized version would be.

1reaction
mfusseneggercommented, Nov 20, 2019

Currently there is no built-in method for this, but you could create a javascript UDF to return the keys of an object as array and then use it together with unnest to turn the arrays into rows.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calculating 2 object keys/columns from array ... - Stack Overflow
You may destructure your object properties and sum up desired ones, using Array.prototype.reduce() :.
Read more >
Object.getOwnPropertyNames() - JavaScript - MDN Web Docs
The Object.getOwnPropertyNames() method returns an array of all properties (including non-enumerable properties except for those which use Symbol) found ...
Read more >
Map JavaScript Object Keys Using React | Pluralsight
In this guide, you will learn how to map over a JavaScript object's keys in a variety of ways so that you can...
Read more >
Adding primary keys to user-defined objects - IBM
Primary keys can be added to user-defined objects to uniquely identify these objects in a database. A primary index is automatically created for...
Read more >
Semi-structured Data Types - Snowflake Documentation
Strictly speaking, OBJECT is the only one of these data types that, by itself, ... (in different key-value pairs) can have different underlying...
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