Skip to content

Web console: improve SQL autocomplete and add JSON autocomplete #18126

Merged
vogievetsky merged 44 commits intoapache:masterfrom
vogievetsky:fix_autocomplete
Jul 1, 2025
Merged

Web console: improve SQL autocomplete and add JSON autocomplete #18126
vogievetsky merged 44 commits intoapache:masterfrom
vogievetsky:fix_autocomplete

Conversation

@vogievetsky
Copy link
Copy Markdown
Contributor

Fixes #17628

Made the SQL autocomplete much smarter

image

(note how it is not trying to auto-complete functions and other nonsense)

Also added autocomplete to JSON native queries and to all the JSON entry fields

image image

Comment thread web-console/src/utils/hjson-context.ts Fixed
Comment thread web-console/src/utils/hjson-context.ts Fixed
Copy link
Copy Markdown
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh man, that is a lot of API to review, i'll be real here and admit that so far i just scanned it and picked on the things that stuck out.

what are we going for here, is the thinking that mostly correct is better than nothing? or should we try to review this more closely to ensure it is accurate? what is the plan for maintenance, should PR authors update this when they update stuff? I don't have many strong opinions either way yet, just some thoughts that come to mind after looking over this.

All that said, this is pretty cool though 😎

isObject: true,
condition: obj => obj.type === 'index_parallel' || obj.type === 'index',
completions: [
{ value: 'firehose', documentation: 'Legacy data input (deprecated)' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is gone, not just deprecated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

completions: [
{ value: 'uris', documentation: 'List of HTTP/HTTPS URIs' },
{ value: 'httpAuthenticationUsername', documentation: 'HTTP authentication username' },
{ value: 'httpAuthenticationPassword', documentation: 'HTTP authentication password' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are a couple missing ones here, systemFields and requestHeaders though the latter isn't documented either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add systemFields and will add requestHeaders when it is documented

{
path: '$',
isObject: true,
condition: obj => obj.queryType !== 'dataSourceMetadata',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik, everything has a context and intervals, even dataSourceMetadata

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, it is not documented here: https://druid.apache.org/docs/latest/querying/datasourcemetadataquery/ I even double cheched this one. It kind of makes sense for dataSourceMetadata not to support intervals since it is reporting back the max ingested time.

{
path: '$.filter.type',
completions: [
{ value: 'selector', documentation: 'Matches a specific dimension value' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing the range filter and typed in filter (which i just realized isn't documented yet, from #16039)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sticking only to the documented stuff for now

value: 'populateResultLevelCache',
documentation: 'Whether to populate result level cache',
},
{ value: 'bySegment', documentation: 'Return results by segment' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still break the results if you actually set it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bySegment: true should work :-)

* For automatic compaction, set the type to autocompact."
*/
function isSupervisorType(type: string): boolean {
return type === 'kafka' || type === 'kinesis' || type === 'rabbit' || type === 'autocompact';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the scheduled batch supervisor, #17353

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

{ value: 'timestampSpec', documentation: 'Timestamp specification of data in segments' },
{ value: 'queryGranularity', documentation: 'Query granularity of data in segments' },
{ value: 'aggregators', documentation: 'List of aggregators usable for metric columns' },
{ value: 'rollup', documentation: 'Whether the segments are rolled up' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#18119 recently added a projection analysis type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

export const COMPACTION_CONFIG_COMPLETIONS: JsonCompletionRule[] = [
// Root level properties
{
path: '$',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't really correct, after #17803 there is a "type" for a datasource compaction config, with the old spec type being "inline" and the one added in that PR is "catalog"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add that when the docs are up

@vogievetsky
Copy link
Copy Markdown
Contributor Author

Thank you for the review and feedback @clintropolis in general I have taken the approach of only going after the documented properties. I also think of these JSON completions as best effort. It is ok for them to miss stuff. Even if they are totally wrong it is not a blocker (even though it is best to fix) as the completions are purely cosmetic.

As for updating I expect the completions to be updated like like the properties for rendering all the AutoForms. Ideally done by the dev adding a new property in their PR but more often done after the fact once that property is exposed and documented

@vogievetsky vogievetsky added this to the 34.0.0 milestone Jun 24, 2025
Copy link
Copy Markdown
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving because i think this does more help than harm, but I still am a bit wary about long term maintainability. In its current state it seems like maybe we just have to like periodically ask claude (or some similar bot) to refresh it to match the docs? It would be really nice to like consolidate the common definitions across the completion files somehow so that human devs could potentially proactively add or adjust stuff here, but not a blocker.

Still, neat overall 🤘

Comment thread web-console/lib/keywords.ts Outdated
Comment on lines +42 to +43
'DOW',
'DOW',
Copy link
Copy Markdown
Member

@clintropolis clintropolis Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do dupes matter? also this doesn't work in druid (and a bunch of others in this list), though I guess calcite recognizes it since i see it in the parser stuff 🤷

path: '$.spec.dataSchema.dimensionsSpec.useSchemaDiscovery',
completions: [
{ value: 'true', documentation: 'Enable automatic type detection and schema discovery' },
{ value: 'false', documentation: 'Use manual dimension specification (default)' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is perhaps misleading since you can still discover dimensions by leaving the list empty OR by specifying includeAllDimension as true.. though maybe that makes it even more confusing..

Comment on lines +197 to +198
{ value: 'true', documentation: 'Create bitmap index (default, faster filtering)' },
{ value: 'false', documentation: 'No bitmap index (saves storage)' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we indicate that this only works for string type dimensions?

Comment on lines +205 to +207
{ value: 'sorted_array', documentation: 'Sort multi-values (default)' },
{ value: 'sorted_set', documentation: 'Sort and deduplicate multi-values' },
{ value: 'array', documentation: 'Keep multi-values as-is' },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we mention this only works for string type dimensions?


// Aggregation types
{
path: '$.aggregations.[].type',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've noticed this repeated quite a lot across the completions (and also some other common components like filters), is there a way to share it perhaps? fine to do as a follow-up, but sharing common elements across query, ingestion, compaction, etc would help make this a ton more maintainable

@vogievetsky
Copy link
Copy Markdown
Contributor Author

I think the feedback all makes sense. I also think this PR makes things a lot better. In a follow up PR I will change this behaviour to use json-schema which is a standard and allows for recursive schema definition

@vogievetsky vogievetsky merged commit f46124b into apache:master Jul 1, 2025
10 checks passed
@vogievetsky vogievetsky deleted the fix_autocomplete branch July 1, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workbench autocomplete should be smater

3 participants