From a03ac4f75ff38a3c76e36b519eefa57ffcc5974c Mon Sep 17 00:00:00 2001 From: Stelios Voutsinas Date: Mon, 10 Jun 2024 12:05:12 -0700 Subject: [PATCH 1/5] Add PgsphereDeParser / Fixes issue with quotes not being removed from colunm names --- tap/src/main/java/ca/nrc/cadc/sample/AdqlQueryImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tap/src/main/java/ca/nrc/cadc/sample/AdqlQueryImpl.java b/tap/src/main/java/ca/nrc/cadc/sample/AdqlQueryImpl.java index e9c891c..fc92c88 100644 --- a/tap/src/main/java/ca/nrc/cadc/sample/AdqlQueryImpl.java +++ b/tap/src/main/java/ca/nrc/cadc/sample/AdqlQueryImpl.java @@ -72,6 +72,9 @@ import ca.nrc.cadc.tap.AdqlQuery; import ca.nrc.cadc.tap.parser.converter.TableNameConverter; import ca.nrc.cadc.tap.parser.converter.TableNameReferenceConverter; +import ca.nrc.cadc.tap.parser.BaseExpressionDeParser; +import ca.nrc.cadc.tap.parser.PgsphereDeParser; +import net.sf.jsqlparser.util.deparser.SelectDeParser; import ca.nrc.cadc.tap.parser.converter.TopConverter; import ca.nrc.cadc.tap.parser.navigator.ExpressionNavigator; import ca.nrc.cadc.tap.parser.navigator.FromItemNavigator; @@ -117,4 +120,10 @@ protected void init() // TODO: add more custom query visitors here } + + @Override + protected BaseExpressionDeParser getExpressionDeparser(SelectDeParser dep, StringBuffer sb) { + return new PgsphereDeParser(dep, sb); + } + } From 366b065732834c8919f3fbf876be99efdcc48385 Mon Sep 17 00:00:00 2001 From: Stelios Voutsinas Date: Mon, 10 Jun 2024 12:06:56 -0700 Subject: [PATCH 2/5] Added scriv message --- changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst diff --git a/changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst b/changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst new file mode 100644 index 0000000..3e57d0c --- /dev/null +++ b/changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst @@ -0,0 +1,3 @@ +Fixed +----- +- Added PgsphereDeParser to AdqlQueryImpl / Fixes issue with queries having quotes around column names ("size") From f0b3942d61edf85f286b84e2d7c5909db73d7ec8 Mon Sep 17 00:00:00 2001 From: Stelios Voutsinas Date: Mon, 10 Jun 2024 12:51:02 -0700 Subject: [PATCH 3/5] Added changelog messages --- CHANGELOG.md | 18 +++++++++++++++++- ...0610_190526_steliosvoutsinas_parser_fix.rst | 3 --- changelog.d/scriv.ini | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) delete mode 100644 changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst create mode 100644 changelog.d/scriv.ini diff --git a/CHANGELOG.md b/CHANGELOG.md index 1edf371..ca544b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,23 @@ Find changes for the upcoming release in the project's [changelog.d](https://git - + + +## 1.16.0 (2024-06-10) + +### Fixed + +- Added PgsphereDeParser to AdqlQueryImpl / Fixes issue with queries having quotes around column names ("size") + + +## 1.17.0 (2024-06-07) + +## Changed + +- Bump cadc dependency versions & switch to using cadc-tomcat image by @stvoutsin in #28 + + + ## 1.16.0 (2024-05-30) ### New features diff --git a/changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst b/changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst deleted file mode 100644 index 3e57d0c..0000000 --- a/changelog.d/20240610_190526_steliosvoutsinas_parser_fix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed ------ -- Added PgsphereDeParser to AdqlQueryImpl / Fixes issue with queries having quotes around column names ("size") diff --git a/changelog.d/scriv.ini b/changelog.d/scriv.ini new file mode 100644 index 0000000..592bc12 --- /dev/null +++ b/changelog.d/scriv.ini @@ -0,0 +1,2 @@ +[scriv] +format = md From 641829764b5db0212e6ba12b3f7479d2fc9593e9 Mon Sep 17 00:00:00 2001 From: Stelios Voutsinas Date: Mon, 10 Jun 2024 12:57:38 -0700 Subject: [PATCH 4/5] Fix version number in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca544b0..ad7b4bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Find changes for the upcoming release in the project's [changelog.d](https://git -## 1.16.0 (2024-06-10) +## 1.17.1 (2024-06-10) ### Fixed From d7bcae1e8d3212220698bc967152047abaa08242 Mon Sep 17 00:00:00 2001 From: Stelios Voutsinas Date: Mon, 10 Jun 2024 14:05:53 -0700 Subject: [PATCH 5/5] Added a Unit test for size --- .../ca/nrc/cadc/sample/AdqlQueryImplTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tap/src/test/java/ca/nrc/cadc/sample/AdqlQueryImplTest.java b/tap/src/test/java/ca/nrc/cadc/sample/AdqlQueryImplTest.java index 7308c55..4420573 100644 --- a/tap/src/test/java/ca/nrc/cadc/sample/AdqlQueryImplTest.java +++ b/tap/src/test/java/ca/nrc/cadc/sample/AdqlQueryImplTest.java @@ -168,18 +168,54 @@ public void testTopConverter() } } + // Test that a query using size works as expected (No quotes) + @Test + public void testQueryWithSizeConverter() + { + try + { + job.getParameterList().add(new Parameter("QUERY", "select top 5 * from test.tables as t")); + + AdqlQueryImpl q = new AdqlQueryImpl(); + q.setJob(job); + q.setTapSchema(mockTapSchema()); + + String sql = q.getSQL(); + log.debug("SQL: " + sql); + Assert.assertNotNull("sql", sql); + sql = sql.toLowerCase(); + int i = sql.indexOf("select") + 6; + int j = sql.indexOf("from") - 1; + String selectList = sql.substring(i, j); + log.debug("select-list: " + selectList); + Assert.assertTrue(selectList.contains("t.size")); + } + catch(Exception unexpected) + { + log.error("unexpected exception", unexpected); + Assert.fail("unexpected exception: " + unexpected); + } + finally + { + job.getParameterList().clear(); + } + } + TapSchema mockTapSchema() { TapSchema ret = new TapSchema(); SchemaDesc sd = new SchemaDesc("test"); TableDesc foo = new TableDesc("test", "test.foo"); TableDesc bar = new TableDesc("test", "test.bar"); + TableDesc tables = new TableDesc("test", "test.tables"); foo.getColumnDescs().add(new ColumnDesc("test.foo", "f1", TapDataType.INTEGER)); foo.getColumnDescs().add(new ColumnDesc("test.foo", "f2", new TapDataType("char", "8", null))); bar.getColumnDescs().add(new ColumnDesc("test.bar", "b1", TapDataType.INTEGER)); bar.getColumnDescs().add(new ColumnDesc("test.bar", "b2", new TapDataType("char", "8", null))); + tables.getColumnDescs().add(new ColumnDesc("test.tables", "size", new TapDataType("char", "8", null))); sd.getTableDescs().add(foo); sd.getTableDescs().add(bar); + sd.getTableDescs().add(tables); ret.getSchemaDescs().add(sd); return ret; }