lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shawn Heisey (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SOLR-2529) DIH update trouble with sql field name "pk"
Date Thu, 09 Jun 2011 17:44:59 GMT

    [ https://issues.apache.org/jira/browse/SOLR-2529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13046695#comment-13046695
] 

Shawn Heisey commented on SOLR-2529:
------------------------------------

I ran into a similar problem, but it had nothing to do with the name of the field.

java.lang.IllegalArgumentException: deltaQuery has no column to resolve to declared primary
key pk='did'

In my dih-config.xml file I have this.  The idea is simply to return a guaranteed result very
quickly, so that it can then execute the deltaImportQuery, which as it happens is identical
to the main query for a full-import:

deltaQuery="SELECT MAX(did) FROM ${dataimporter.request.dataView}"

The result just has a column called MAX(did), not did.  The following change made it work,
because it has the right field name to match the primary key in your DIH config.

deltaQuery="SELECT MAX(did) AS did FROM ${dataimporter.request.dataView}"

Hopefully your problem is similar and can be easily solved in this way, but if not, this issue
will still be here.

> DIH update trouble with sql field name "pk"
> -------------------------------------------
>
>                 Key: SOLR-2529
>                 URL: https://issues.apache.org/jira/browse/SOLR-2529
>             Project: Solr
>          Issue Type: Bug
>          Components: contrib - DataImportHandler
>    Affects Versions: 3.1, 3.2
>         Environment: Debian Lenny, JRE 6
>            Reporter: Thomas Gambier
>            Priority: Blocker
>
> We are unable to use the DIH when database columnName primary key is named "pk".
> The reported solr error is :
> "deltaQuery has no column to resolve to declared primary key pk='pk'"
> We have made some investigations and found that the DIH have a mistake when it's looking
for the primary key between row's columns list.
> private String findMatchingPkColumn(String pk, Map row) {
> if (row.containsKey(pk))
>   throw new IllegalArgumentException(
>     String.format("deltaQuery returned a row with null for primary key %s", pk));
> String resolvedPk = null;
> for (String columnName : row.keySet()) {
>   if (columnName.endsWith("." + pk) || pk.endsWith("." + columnName)) {
>     if (resolvedPk != null)
>       throw new IllegalArgumentException(
>         String.format(
>           "deltaQuery has more than one column (%s and %s) that might resolve to declared
primary key pk='%s'",
>           resolvedPk, columnName, pk));
>       resolvedPk = columnName;
>     }
>   }
>   if (resolvedPk == null)
>     throw new IllegalArgumentException(
>       String.format("deltaQuery has no column to resolve to declared primary key pk='%s'",
pk));
>   LOG.info(String.format("Resolving deltaQuery column '%s' to match entity's declared
pk '%s'", resolvedPk, pk));
>   return resolvedPk;
> }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message