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.

EdgeQLSyntaxError: Unexpected '('

See original GitHub issue

In EdgeDB, I built up a database schema in an .esdl file that has types with commonly shared properties like title and _title. Initially, I thought it would be nice to select either all of the parent type objects, like where (_title := 'CPU'), or instead zoom into just one of the extended child types, like (title := 'CPU_Iowait'). This turned out to be a problem when following the documentation at EdgeDB Documentation where the page suggests using the lexicon index on (__subject__.<prop>).

Expected Behavior

The edgedb-python lex checker should potentially accept a type definition like the following snippet, provided that I haven’t missed something super obvious.

type Host {
    required property title -> str;
    multi link disks -> Disk;
    multi link children -> Host;
    annotation description := 'The Essilor-Luxottica hostname';
    index on (__subject__.title);
}

Current Behavior

When calling:

with open("schema.esdl", "r") as f:
    schema = f.read()
conn = edgedb.connect(...)
with conn.transaction():
    try:
        conn.execute(schema)
    except Exception as e:
        raise(e)

Python returns:

Traceback (most recent call last):
  File "setup.py", line 44, in <module>
    Database.build_schema()
  File "setup.py", line 42, in build_schema
    conn.execute(schema)
  File "setup.py", line 40, in build_schema
    self._protocol.sync_simple_query(query)
  File "edgedb/protocol/blocking_proto.pyx", line 76, in edgedb.protocol.blocking_proto.BlockingIOProtocol.sync_simple_query
  File "edgedb/protocol/blocking_proto.pyx", line 59, in edgedb.protocol.blocking_proto.BlockingIOProtocol._iter_coroutine
  File "edgedb/protocol/protocol.pyx", line 456, in simple_query
edgedb.errors.EdgeQLSyntaxError: Unexpected '('

Context (Environment)

I’ve encountered this error in OS environments Debian 10 and Ubuntu 18.04 using Python 3.7-dev.

Additionally, my schema.esdl file contains the following:

CREATE MIGRATION datatypes TO {
    type Unit {
        property title -> str;
        annotation description := 'The extensible unit type. If unit is `null`, then assign empty-set `{}`.';
    }
    type Rate {
        property title -> str;
        required property value -> float32;
        annotation description := 'The extensible rate type. If rate is `null`, then assign empty-set `{}`.';
    }
    type Resolution {
        required property milliseconds -> int32;
        annotation description := 'Resolution in milliseconds UTC';
    }
    type AggregationType {
        required property title -> str;
        annotation description := 'Any one of ["AVG", "SUM", "MIN", "MAX"]';
    }
    type Time {
        required property utc -> int64;
        annotation description := 'The approximate UTC time as a 64-bit integer';
    }
    type Percent extending Unit {
        required property value -> float32;
        annotation description := 'Ratio of resource unit to resource capacity';
    }
    type Bytes extending Unit {
        required property value -> int64;
        annotation description := 'Number of Bytes as a 64-bit integer';
    }
    type BytesPerSecond extending Rate {
        required property value -> float32;
        annotation description := 'Rate of Bytes per Second (B/s)';
    }
    type Count extending Unit {
        required property value -> int64;
        annotation description := 'The sum of units counted';
    }
    type CountPerSecond extending Rate {
        required property value -> float32;
        annotation description := 'The count of instances per second (count/s)';
    }
    type MilliSeconds extending Unit {
        required property value -> float32;
        annotation description := 'The number of milliseconds';
    }
    type Timeseries {
        annotation description := 'The abstract base type for a dynatrace Timeseries API call';
        required link aggregationType -> AggregationType;
        required link time -> Time;
        required link resolution -> Resolution;
    }
    type Host {
        required property title -> str;
        multi link disks -> Disk;
        multi link children -> Host;
        annotation description := 'The luxottica host group';
        index on (__subject__.title);
    }
    type CPU extending Timeseries {
        property _title -> str; # _title := 'CPU'
        required link value -> Percent;
        multi link hosts -> Host;
        index on (__subject__._title);
    }
    type Disk extending Timeseries {
        property _title -> str; # _title := 'Disk'
        required link host -> Host;
        required property path -> str;
        annotation description := 'The absolute path on a given host.';
        index on (__subject__._title);
    }
    type Memory extending Timeseries {
        property _title -> str; # _title := 'Memory'
        required link host -> Host;
        index on (__subject__._title);
    }
    type CPU_Idle extending CPU {
        property title -> str; # title := 'CPU_Idle'
        annotation description := 'Percent of Idle CPU usage';
        index on (__subject__.title);
    }
    type CPU_Iowait extending CPU {
        property title -> str; # title := 'CPU_Iowait'
        annotation description := 'Percent of Iowait-ing CPU usage';
        index on (__subject__.title);
    }
    type CPU_Other extending CPU {
        property title -> str; # title := 'CPU_Other'
        annotation description := 'Percent of other CPU usage';
        index on (__subject__.title);
    }
    type CPU_Steal extending CPU {
        property title -> str; # title := 'CPU_Steal'
        annotation description := 'Percent of stolen CPU usage'
        index on (__subject__.title);
    }
    type CPU_System extending CPU {
        property title -> str; # title := 'CPU_System'
        annotation description := 'Percent of system CPU usage';
        index on (__subject__.title);
    }
    type CPU_User extending CPU {
        property title -> str; # title := 'CPU_User'
        annotation description := 'Percent of user CPU usage';
        index on (__subject__.title); 
    }
    type Disk_Available extending Disk {
        annotation description := 'Disk space available in bytes (B) broken down by Host->Folder';
        required link value -> Bytes;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_BytesRead extending Disk {
        annotation description := 'Disk read bytes per second (B/s) broken down by Host->Folder';
        required link value -> BytesPerSecond;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_BytesWritten extending Disk {
        annotation description := 'Disk write bytes per second (B/s) broken down by Host->Folder';
        required link value -> BytesPerSecond;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_FreeSpacePercentage extending Disk {
        annotation description := 'Available Disk Percent (%) broken down by Host->Folder';
        required link value -> Percent;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_QueueLength extending Disk {
        annotation description := "Appx count of the disk's queue length for a given host's folder";
        required property value -> float32;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_ReadOperations extending Disk {
        annotation description := "Approximate disk read operations per second (count/s) for a given host's folder";
        required link value -> CountPerSecond;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_ReadTime extending Disk {
        annotation description := "Millisecs of time reading the disk for a given host's folder";
        required link value -> MilliSeconds;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_UsedSpace extending Disk {
        annotation description := 'Num bytes (B) used by the host for a particular disk (folder)';
        required link value -> Bytes;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_WriteOperations extending Disk {
        annotation description := 'Apx # write_ops/s (Count/sec) by a host at a specified folder.';
        required link value -> CountPerSecond;
        property title -> str;
        index on (__subject__.title);
    }
    type Disk_WriteTime extending Disk {
        annotation description := 'MilliSeconds (ms) of time writing to the disk by the host to a particular disk (folder).';
        required link value -> MilliSeconds;
        property title -> str;
        index on (__subject__.title);
    }
    type Memory_Available extending Memory {
        annotation description := 'Bytes of memory avilable on a host';
        required link value -> Bytes;
        property title -> str;
        index on (__subject__.title);
    }
    type Memory_AvailablePercentage extending Memory {
        annotation description := 'Percent of memory available on a host';
        required link value -> Percent;
        property title -> str;
        index on (__subject__.title);
    }
    type Memory_PageFaults extending Memory {
        annotation description := 'Apx # of page_faults/s (Count/sec) on a host';
        required property value -> float32;
        property title -> str;
        index on (__subject__.title);
    }
    type Memory_Used extending Memory {
        annotation description := 'Bytes of memory used on a host';
        required link value -> Bytes;
        property title -> str;
        index on (__subject__.title);
    }
};

COMMIT MIGRATION datatypes;

Miscellaneous

I found a potentially related issue on the main EdgeDB GitHub. If anyone knows the solution to this problem, there’s reputation points up for grabs on Stack Overflow: My Issue

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
1st1commented, Nov 8, 2019

Yeah, a few things:

  1. You have some syntax errors in your ESDL (missing ; in one place, and -> used instead of := in other). You can use edgedb REPL where it will be highlighted.

  2. Our Python driver could do a better job at showing the exact location of the syntax error. The information is transmitted by the server but isn’t rendered. That is bug number 1.

  3. REPL is showing a wall of text instead of showing just the relevant few lines of where the syntax error is located. That’s bug number 2.

We’ll fix both in alpha 2.

1reaction
1st1commented, Nov 12, 2019

Thanks so much for trying it out, @dmgolembiowski! Feel free to ask us any questions any time on GH or at https://spectrum.chat/edgedb!

Please keep in mind that it’s Alpha 1 and a few things will change in the upcoming Alpha 2. From there onward we will have a proper migration path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQLError: Syntax Error: Unexpected "(" - Stack Overflow
I am new to GraphQL and am trying to query the TfL API for a project with React. I am trying to pass...
Read more >
Messages — Binary protocol | EdgeDB Docs
Error span is the range of characters (or equivalent bytes) of the original query that compiler points to as the source of the...
Read more >
Getting syntax error line # at position # unexpected 'ON' for my ...
I'm running a query that left joins two select statements but i'm getting the error "syntax error line # at position # unexpected...
Read more >
Show HN: EdgeDB 1.0 - Hacker News
EdgeQL is a full query language with a standard library, grammar, ... which also brings out surprising performance for wildly nested frontend queries....
Read more >
link log - Tony Finch
2021‑02‑01: PostgreSQL partial indexes: the unexpected find that freed 20GB of unused space. ... 2020‑11‑18: Automatic syntax error recovery in lrpar.
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