Issue when parsing large snomed ontology
I was trying to load snomed using the sparqlify example code and there was a parsing error. I think it comes from the underlying sparqlify library though. Here is the error:
Exception in thread "main" org.apache.spark.sql.catalyst.parser.ParseException:
mismatched input '184298' expecting {'SELECT', 'FROM', 'ADD', 'AS', 'ALL', 'DISTINCT', 'WHERE', 'GROUP', 'BY', 'GROUPING', 'SETS', 'CUBE', 'ROLLUP', 'ORDER', 'HAVING', 'LIMIT', 'AT', 'OR', 'AND', 'IN', NOT, 'NO', 'EXISTS', 'BETWEEN', 'LIKE', RLIKE, 'IS', 'NULL', 'TRUE', 'FALSE', 'NULLS', 'ASC', 'DESC', 'FOR', 'INTERVAL', 'CASE', 'WHEN', 'THEN', 'ELSE', 'END', 'JOIN', 'CROSS', 'OUTER', 'INNER', 'LEFT', 'SEMI', 'RIGHT', 'FULL', 'NATURAL', 'ON', 'LATERAL', 'WINDOW', 'OVER', 'PARTITION', 'RANGE', 'ROWS', 'UNBOUNDED', 'PRECEDING', 'FOLLOWING', 'CURRENT', 'FIRST', 'LAST', 'ROW', 'WITH', 'VALUES', 'CREATE', 'TABLE', 'VIEW', 'REPLACE', 'INSERT', 'DELETE', 'INTO', 'DESCRIBE', 'EXPLAIN', 'FORMAT', 'LOGICAL', 'CODEGEN', 'CAST', 'SHOW', 'TABLES', 'COLUMNS', 'COLUMN', 'USE', 'PARTITIONS', 'FUNCTIONS', 'DROP', 'UNION', 'EXCEPT', 'MINUS', 'INTERSECT', 'TO', 'TABLESAMPLE', 'STRATIFY', 'ALTER', 'RENAME', 'ARRAY', 'MAP', 'STRUCT', 'COMMENT', 'SET', 'RESET', 'DATA', 'START', 'TRANSACTION', 'COMMIT', 'ROLLBACK', 'MACRO', 'IF', 'DIV', 'PERCENT', 'BUCKET', 'OUT', 'OF', 'SORT', 'CLUSTER', 'DISTRIBUTE', 'OVERWRITE', 'TRANSFORM', 'REDUCE', 'USING', 'SERDE', 'SERDEPROPERTIES', 'RECORDREADER', 'RECORDWRITER', 'DELIMITED', 'FIELDS', 'TERMINATED', 'COLLECTION', 'ITEMS', 'KEYS', 'ESCAPED', 'LINES', 'SEPARATED', 'FUNCTION', 'EXTENDED', 'REFRESH', 'CLEAR', 'CACHE', 'UNCACHE', 'LAZY', 'FORMATTED', 'GLOBAL', TEMPORARY, 'OPTIONS', 'UNSET', 'TBLPROPERTIES', 'DBPROPERTIES', 'BUCKETS', 'SKEWED', 'STORED', 'DIRECTORIES', 'LOCATION', 'EXCHANGE', 'ARCHIVE', 'UNARCHIVE', 'FILEFORMAT', 'TOUCH', 'COMPACT', 'CONCATENATE', 'CHANGE', 'CASCADE', 'RESTRICT', 'CLUSTERED', 'SORTED', 'PURGE', 'INPUTFORMAT', 'OUTPUTFORMAT', DATABASE, DATABASES, 'DFS', 'TRUNCATE', 'ANALYZE', 'COMPUTE', 'LIST', 'STATISTICS', 'PARTITIONED', 'EXTERNAL', 'DEFINED', 'REVOKE', 'GRANT', 'LOCK', 'UNLOCK', 'MSCK', 'REPAIR', 'RECOVER', 'EXPORT', 'IMPORT', 'LOAD', 'ROLE', 'ROLES', 'COMPACTIONS', 'PRINCIPALS', 'TRANSACTIONS', 'INDEX', 'INDEXES', 'LOCKS', 'OPTION', 'ANTI', 'LOCAL', 'INPATH', 'CURRENT_DATE', 'CURRENT_TIMESTAMP', IDENTIFIER, BACKQUOTED_IDENTIFIER}(line 1, pos 0)
== SQL ==
184298
^^^
at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:197)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:99)
at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:45)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parseTableIdentifier(ParseDriver.scala:48)
at org.apache.spark.sql.Dataset.org$apache$spark$sql$Dataset$$createTempViewCommand(Dataset.scala:2657)
at org.apache.spark.sql.Dataset$$anonfun$createOrReplaceTempView$1.apply(Dataset.scala:2629)
at org.apache.spark.sql.Dataset$$anonfun$createOrReplaceTempView$1.apply(Dataset.scala:2629)
at org.apache.spark.sql.Dataset.org$apache$spark$sql$Dataset$$withPlan(Dataset.scala:2845)
at org.apache.spark.sql.Dataset.createOrReplaceTempView(Dataset.scala:2628)
at net.sansa_stack.query.spark.sparqlify.SparqlifyUtils3$$anonfun$1.apply(SparqlifyUtils3.scala:62)
at net.sansa_stack.query.spark.sparqlify.SparqlifyUtils3$$anonfun$1.apply(SparqlifyUtils3.scala:45)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:221)
at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:428)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at net.sansa_stack.query.spark.sparqlify.SparqlifyUtils3$.createSparqlSqlRewriter(SparqlifyUtils3.scala:45)
at net.sansa_stack.examples.spark.query.Sparklify$.run(Sparklify.scala:48)
at net.sansa_stack.examples.spark.query.Sparklify$.main(Sparklify.scala:24)
at net.sansa_stack.examples.spark.query.Sparklify.main(Sparklify.scala)
Process finished with exit code 1
I deleted a lot of the original ontology and this minimal file produces the same error:
<http://snomedct-20170731T150000Z> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Ontology> .
<http://snomedct-20170731T150000Z> <http://sourceName> "SNOMEDCT" .
<http://snomedct-20170731T150000Z> <http://www.w3.org/2000/01/rdf-schema#comment> "SNOMED Ontology (international)"@en .
<http://snomedct-20170731T150000Z> <http://www.w3.org/2002/07/owl#versionInfo> "20170731T150000Z"@en .
<http://snomedct-20170731T150000Z> <http://www.w3.org/2004/02/skos/core#prefLabel> "SNOMED (International)"@en .
#
#
# #################################################################
# #
# # Annotation properties
# #
# #################################################################
#
#
#
# http://someOnt/184298
<http://someOnt/184298> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#AnnotationProperty> .
<http://someOnt/184298> <http://www.w3.org/2004/02/skos/core#altLabel> "Finding site (attribute)"@en .
<http://someOnt/184298> <http://www.w3.org/2004/02/skos/core#prefLabel> "Finding site"@en .
#
#
#
# #################################################################
# #
# # Classes
# #
# #################################################################
#
#
<http://someOnt/1> <http://someOnt/184298> <http://someOnt/272277> .
It seems to be something to do with using object properties defined in the same file...
So far I could partly fix the issue; for SELECT the example is working.
For CONSTRUCT queries, the underlying jena serializers fail at least for XML:
<http://someOnt/184298> Jena raises org.apache.jena.shared.InvalidPropertyURIException: http://someOnt/184298
However, this is valid behavior for invalid URIs.
We may need to discuss whether to perform additional checks in order to inform users of issues early at data loading time in a separate issue.
Closing it as it should be fixed.