Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-1230

SPARQL parser should not automatically inject PREFIX declarations

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: BLAZEGRAPH_RELEASE_1_5_1
    • Fix Version/s: None
    • Component/s: Bigdata RDF Database
    • Labels:
      None

      Description

      Per BLZG-1218 this is causing very misleading line numbers in SPARQL syntax errors.

        Activity

        Hide
        bryanthompson bryanthompson added a comment -

        This is caused by PrefixDeclsProcessor

            public static final Map<String,String> defaultDecls =
                    new LinkedHashMap<String, String>();
            
            static {
                defaultDecls.put("rdf", RDF.NAMESPACE);
                defaultDecls.put("rdfs", RDFS.NAMESPACE);
                defaultDecls.put("sesame", SESAME.NAMESPACE);
                defaultDecls.put("owl", OWL.NAMESPACE);
                defaultDecls.put("xsd", XMLSchema.NAMESPACE);
                defaultDecls.put("fn", FN.NAMESPACE);
                defaultDecls.put("foaf", FOAF.NAMESPACE);
                defaultDecls.put("dc", DC.NAMESPACE);
                defaultDecls.put("hint", QueryHints.NAMESPACE);
                defaultDecls.put("bd", BD.NAMESPACE);
                defaultDecls.put("bds", BDS.NAMESPACE);
            }
        
                // insert some default prefixes (if not explicitly defined in the query)
        ...
                for (Map.Entry<String, String> e : defaultDecls.entrySet()) {
                    insertDefaultPrefix(prefixMap, e.getKey(), e.getValue());
                }
        

        There are 133 references to that defaultDecls, most of which are in test cases. Those will need to be modified to only test for the actually specified (or implicitly declared in the case where the test fails to declare the prefix) prefixes. I think that tests (other than explicit tests of this implicit prefix declaration capability) should always explicitly declare their prefixes. They should not be relying on this slight of hand inside of the PrefixDeclProcessor. The purpose of that bit of magic is just to make it easier on people who fail to include well known prefix declarations in their queries. (Encouraging this practice is perhaps a bad idea. It certainly promotes non-portable code.)

        Show
        bryanthompson bryanthompson added a comment - This is caused by PrefixDeclsProcessor public static final Map<String,String> defaultDecls = new LinkedHashMap<String, String>(); static { defaultDecls.put("rdf", RDF.NAMESPACE); defaultDecls.put("rdfs", RDFS.NAMESPACE); defaultDecls.put("sesame", SESAME.NAMESPACE); defaultDecls.put("owl", OWL.NAMESPACE); defaultDecls.put("xsd", XMLSchema.NAMESPACE); defaultDecls.put("fn", FN.NAMESPACE); defaultDecls.put("foaf", FOAF.NAMESPACE); defaultDecls.put("dc", DC.NAMESPACE); defaultDecls.put("hint", QueryHints.NAMESPACE); defaultDecls.put("bd", BD.NAMESPACE); defaultDecls.put("bds", BDS.NAMESPACE); } // insert some default prefixes (if not explicitly defined in the query) ... for (Map.Entry<String, String> e : defaultDecls.entrySet()) { insertDefaultPrefix(prefixMap, e.getKey(), e.getValue()); } There are 133 references to that defaultDecls, most of which are in test cases. Those will need to be modified to only test for the actually specified (or implicitly declared in the case where the test fails to declare the prefix) prefixes. I think that tests (other than explicit tests of this implicit prefix declaration capability) should always explicitly declare their prefixes. They should not be relying on this slight of hand inside of the PrefixDeclProcessor. The purpose of that bit of magic is just to make it easier on people who fail to include well known prefix declarations in their queries. (Encouraging this practice is perhaps a bad idea. It certainly promotes non-portable code.)

          People

          • Assignee:
            bryanthompson bryanthompson
            Reporter:
            bryanthompson bryanthompson
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: