Opened 16 years ago

Closed 16 years ago

#941 closed defect (fixed)

SQLException when exporting "merged on reporters" with BioAssaySet exporter on Postgres

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: critical Milestone: BASE 2.6.1
Component: coreplugins Version:
Keywords: Cc:


This may be related to #939, but I am not sure. In any case, here is how to reproduce it:

  1. Assuming that you have an experiment with some data analyzed in it
  2. Go to the Bioassaysets tree view
  3. Choose any bioassayset and click on the Export tool. Select the Bioassay set file exporter plugin.
  4. Choose BASEFile as the file format and then on the next page
    • Average on reporters = true
    • Export as matrix or serial file = matrix
    • Fields and reporter doesn't matter
  5. Download the exported file and open it in an editor
  6. The contents of the file is a stacktrace:
net.sf.basedb.core.BaseException: ERROR: column "spt.position" must appear in the GROUP BY clause or be used in an aggregate function
	at net.sf.basedb.core.AbstractSqlQuery.iterate(
	at net.sf.basedb.core.DynamicQuery.iterate(
	at net.sf.basedb.plugins.BioAssaySetExporter.exportBaseFileSectionSpots(
	at net.sf.basedb.plugins.BioAssaySetExporter.exportBaseFileMatrix(
	at net.sf.basedb.plugins.BioAssaySetExporter.performExport(
	at net.sf.basedb.core.plugin.AbstractExporterPlugin.doExport(
	at net.sf.basedb.core.PluginResponse.downloadImmediately(
	at org.apache.jsp.common.plugin.index_jsp._jspService(
	at org.apache.jasper.runtime.HttpJspBase.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.jasper.servlet.JspServletWrapper.service(
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(
	at org.apache.jasper.servlet.JspServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at net.sf.basedb.clients.web.servlet.CharacterEncodingFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
	at org.apache.tomcat.util.threads.ThreadPool$
Caused by: org.postgresql.util.PSQLException: ERROR: column "spt.position" must appear in the GROUP BY clause or be used in an aggregate function
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(
	at org.postgresql.core.v3.QueryExecutorImpl.execute(
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(
	at net.sf.basedb.core.QueryExecutor$
	at net.sf.basedb.core.QueryExecutor$
	at java.util.concurrent.FutureTask$Sync.innerRun(
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
	at java.util.concurrent.ThreadPoolExecutor$
	... 1 more

The problem is that when merging on reporters there is GROUP BY clause on the query. The "position" column is not in the GROUP BY and thus, it can't be used in the SELECT part either (unless we use COUNT(position), AVG(position), etc. but those expressions has no meaning.

So, the "position" must be removed from the query when merging on reporters. The problem with this is that the export code seems to base a lot of it's logic based on the position number. For example, to fill in blanks to make sure the columns line up when there are missing values in the data. So, when merging on reporter the position value must be replaced by something else, possible the reporter ID.

MySQL isn't very picky about this and allows the query to run. The problem is that for each reporter it selects a random position value from the merged reporters. This value may be different for different bioassays which means that the columns doesn't line up and that the same reporter is appearing on more than one line (a new line is started each time the position value changes). I guess this is the effect that is seen in ticket #939.

Change History (2)

comment:1 by Nicklas Nordborg, 16 years ago

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:2 by Nicklas Nordborg, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [4167]) Fixes #941: SQLException when exporting "merged on reporters" with BioAssaySet exporter on Postgres References #939: BioAssaySetExporter doesn't export BASEfiles for multiple array designs correctly

Note: See TracTickets for help on using tickets.