kakao / s2graph

This code base is retained for historical interest only, please visit Apache Incubator Repo for latest one
https://github.com/apache/incubator-s2graph
Other
250 stars 32 forks source link

S2AB string variable handling can cause error in "where" options. #95

Closed HyunsungJo closed 8 years ago

HyunsungJo commented 8 years ago

Problem

Think of an S2AB bucket defined as below:

{
    "srcVertices": [
        {
            "serviceName": "some_service",
            "columnName": "article_id",
            "id": [[doc_id]]
        }
    ],
    "steps": [
        {
            "step": [
                {
                    "label": "similar_articles",
                    "direction": "out",
                    "offset": 0,
                    "limit": 10,
                    "where": "is_blacklisted_article=false and article_id != [[doc_id]]"
                }
            ]
        }
    ]
}

According to the current spec, client will make the following call:

curl -XPOST http://graph-query.iwilab.com:9000/graphs/experiment/{app key}/{experiment name}/{uuid} -H 'Content-Type: Application/json' -d '
{
  "[[doc_id]]": "some-string-id"
}
'

And this will return an error due to nested double quotes in the "where" field.

"where": "is_blacklisted_article=false and article_id != "some-string-id""

Solution

Everyone would be happy if

  1. the variable [[doc_id]] is replaced with some-string-id instead of "some-string-id" (without the quotation marks..),
  2. and the bucket is defined as such:
{
    "srcVertices": [
        {
            "serviceName": "some_service",
            "columnName": "article_id",
            "id": "[[doc_id]]"     <=== quotation marks added!
        }
    ],
    "steps": [
        {
            "step": [
                {
                    "label": "similar_articles",
                    "direction": "out",
                    "offset": 0,
                    "limit": 10,
                    "where": "is_blacklisted_article=false and article_id != [[doc_id]]"
                }
            ]
        }
    ]
}
SteamShon commented 8 years ago

:+1: