EdgeQLSyntaxError: Unexpected '('
See original GitHub issueIn 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:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Yeah, a few things:
You have some syntax errors in your ESDL (missing
;
in one place, and->
used instead of:=
in other). You can useedgedb
REPL where it will be highlighted.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.
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.
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.