通过Ajax从Google Fusion Table得到的结果部分不正确,但是通过图表工具得到了正确的结果吗? [英] Partially incorrect results from Google Fusion Table via Ajax, but correct via Chart Tools?

查看:61
本文介绍了通过Ajax从Google Fusion Table得到的结果部分不正确,但是通过图表工具得到了正确的结果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

学习Google FusionTables,因此可能会犯一个非常初学者的错误.通过ChartTools API而不通过Ajax API查询Google Fusion Tables时,我得到正确的结果.奇怪的是,它为部分查询(而不是全部查询)提供了正确的结果.我在弄错吗?

图表工具API可以运行: 通过图表工具API查询Google FusionTable似乎可以正常进行,尽管行数限制为500.例如,此查询:SELECT ETHUN, COUNT() FROM 1Nynh5pPrj1q8JqbalppAm-qzAsgKvL0ZRala7VI GROUP BY ETHUN

使用Google Chart Tools API,URL为

为什么会给我NaN而不是{1,2,-9}?

更新: 我现在认为这个问题是新的Fusion Tables SQL所特有的,对此问题进行了稍微的编辑.

(这是示例融合表的链接)

>

融合表SQL API(现已弃用)

奇怪的是,此链接也可以正常使用,

这似乎是Google Fusion Tables API v1.0的错误.此错误特定于数字字段. Ajax能够正确查询String字段就好了.只是此数据集主要包含数字字段.

Learning Google FusionTables, so possibly making a very beginner mistake. I get correct results when querying Google Fusion Tables via the ChartTools API but not via the Ajax API. Strangely, it gives correct results for part of the query, just not all of it. Am I making a mistake?

Chart Tools API works: Querying Google FusionTable via the Chart Tools API seems to work fine, albeit with a 500 row limit. For instance, this query: SELECT ETHUN, COUNT() FROM 1Nynh5pPrj1q8JqbalppAm-qzAsgKvL0ZRala7VI GROUP BY ETHUN

Using the Google Chart Tools API, the URL is http://www.google.com/fusiontables/gvizdata?tq=SELECT%20ETHUN%2C%20COUNT()%20%20FROM%201Nynh5pPrj1q8JqbalppAm-qzAsgKvL0ZRala7VI%20GROUP%20BY%20ETHUN&tqx=reqId%3A0, which returns a JSON function:

google.visualization.Query.setResponse({
    version:'0.5',
    reqId:'0',status:'ok',
    table:{
        p:{totalrows:3},
        cols:[
            {id:'col6',label:'ETHUN',type:'number'},           
            {id:'#agg#COUNT',label:'count()',type:'number'}
        ],
        rows:[
            {c:[{v:1.0},{v:3308.0}]}
            {c:[{v:2.0},{v:18702.0}]},
            {c:[{v:-9.0},{v:10768.0}]},
        ]
     }
 })

In particular, note the values {1,2,-9} as the values for ETHUN.

New FusionTables API doesnt work: On the other hand, making the same query via the Ajax API returns correct frequencies but NaN for the values themselves that the frequencies describe: https://www.googleapis.com/fusiontables/v1/query?sql=SELECT%20ETHUN%2C%20COUNT()%20%20FROM%201Nynh5pPrj1q8JqbalppAm-qzAsgKvL0ZRala7VI%20GROUP%20BY%20ETHUN&key=AIzaSyBT_ZCriV-Tm78KsJiQp6KKhjDwMhP0tYM

Which returns this JSON:

{
 "kind": "fusiontables#sqlresponse",
 "columns": [ "ETHUN",  "count()"  ],
 "rows": [
  [  NaN,  "3308" ]
  [  NaN, "18702" ],
  [  NaN, "10768" ],
 ]
}

Why might it be giving me NaN's instead of {1, 2, -9} ?

Update: I now believe this issue is unique to the new Fusion Tables SQL, question slightly edited.

(Here's the link to the example Fusion Table)

Fusion Tables SQL API (now deprecated) also works

Strangely this link also works fine, https://www.google.com/fusiontables/api/query?sql=SELECT%20ETHUN,%20COUNT%28%29%20FROM%204579147%20GROUP%20BY%20ETHUN&alt=json-in-script&jsonCallback=onResponse and returns the following JSONP response with yet another format:

onResponse({"table":{"cols":["ETHUN","count()"],"rows":[["2",18702],["-9",10768],["1",3308]]}})

解决方案

This appears to be a bug with Google Fusion Tables API v1.0. This error is specific to numeric fields. Ajax is able to correctly query String fields just fine. Just this dataset has mostly numeric fields.

这篇关于通过Ajax从Google Fusion Table得到的结果部分不正确,但是通过图表工具得到了正确的结果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆