Skip to content

Make SQL more generic #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged

Conversation

ialarmedalien
Copy link
Contributor

@ialarmedalien ialarmedalien commented Feb 13, 2025

KBase is currently using the semsql schema with a MySQL database and is likely to use it with other SQL db types in the future. This PR alters a couple of lines to use more generic syntax.

Not sure whether I need to propagate these changes to the various other SQL files and the linkml schema.

Turn off whitespace changes - I didn't realise there were so many trailing spaces in the original file!

PRIMARY KEY (id)
);

DROP TABLE statements;
CREATE TABLE statements (stanza TEXT,subject TEXT,predicate TEXT,object TEXT,value TEXT,datatype TEXT,language TEXT);
CREATE TABLE statements (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

formatting this like the other declarations

@@ -1493,15 +1501,17 @@ CREATE VIEW property_used_with_datatype_values_and_objects AS SELECT
s1.predicate AS subject,
s1.predicate,
s1.datatype AS value
FROM statements AS s1, statements AS s2 ON (s1.predicate=s2.predicate)
FROM statements AS s1
JOIN statements AS s2 ON (s1.predicate=s2.predicate)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MySQL doesn't understand , for JOINs so making it explicit

Comment on lines +1603 to +1604
-- patch statements table
ALTER TABLE statements ADD COLUMN graph TEXT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This currently gets added in the build.Makefile. Is there a reason for not adding it to the schema?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We wanted to avoid it going into the SQL models, because that would cause errors on older sqlite builds when using that version of semsql (e.g. in OAK). This has been out for some time so we should just put it into the schema for the next release in the minor series

Copy link
Collaborator

Choose a reason for hiding this comment

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

I remembered the reason. rdftab is hardwired for fewer columns, so this has to be done as postprocessing for now.

@cmungall
Copy link
Collaborator

I'll merge this but it will get overridden next generation time, here is the upstream culprit:

https://github.com/linkml/linkml/blob/a49b69df1516b40153b709b605a4611fff304154/linkml/generators/sqltablegen.py#L210-L211

@cmungall cmungall merged commit 64a1df4 into INCATools:main Feb 21, 2025
2 checks passed
@@ -1318,7 +1326,7 @@ DROP TABLE owl_reified_axiom;
CREATE VIEW owl_reified_axiom AS SELECT axs.subject AS id, axs.stanza AS stanza, axs.object AS subject, axp.object AS predicate, axo.object AS object, axo.value AS value, axo.datatype AS datatype, axo.language AS language FROM statements AS axs, statements AS axp, statements AS axo WHERE axs.predicate = 'owl:annotatedSource' AND axp.predicate = 'owl:annotatedProperty' AND axo.predicate = 'owl:annotatedTarget' AND axs.subject = axp.subject AND axs.subject = axo.subject;

DROP TABLE owl_axiom;
CREATE VIEW owl_axiom AS SELECT * FROM owl_reified_axiom UNION SELECT NULL AS id, * FROM statements;
CREATE VIEW owl_axiom AS SELECT * FROM owl_reified_axiom UNION SELECT NULL AS id, statements.* FROM statements;
Copy link
Collaborator

Choose a reason for hiding this comment

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

- sqlview>> SELECT * FROM owl_reified_axiom UNION SELECT NULL AS id, * FROM statements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants