缩进在SQL中重要吗? [英] Does indentation matter in SQL?

查看:85
本文介绍了缩进在SQL中重要吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Kaggle上做一个微型课程,在该课程上,两个看似相同的块(除了缩进)会产生不同的结果.

I'm doing a microcourse on Kaggle on which two seemingly identical blocks (except the indentation) produce different results.

1.

answers_query = """
                SELECT a.id, a.body, a.owner_user_id
                FROM `bigquery-public-data.stackoverflow.posts_questions` AS q 
                INNER JOIN `bigquery-public-data.stackoverflow.posts_answers` AS a
                ON q.id = a.parent_id
                WHERE q.tags LIKE '%bigquery%'
                """
# Set up the query
safe_config = bigquery.QueryJobConfig(maximum_bytes_billed=10**10)
answers_query_job = client.query(answers_query, job_config = safe_config) # Your code goes here

# API request - run the query, and return a pandas DataFrame
answers_results = answers_query_job.to_dataframe() # Your code goes here

# Preview results
print(answers_results.head())

# Check your answer
q_4.check()

运行此代码,出现以下错误:

Running this code, I get the following error:

400 GET https://dp.kaggle.net/bigquery/v2/projects/kaggle-161607/queries/fdc91d96-2162-4e88-895e-7b0e2ffc377e?maxResults=0&location=US :查询超出了计费字节数的上限:10000000000.需要25131220992或更高版本.

400 GET https://dp.kaggle.net/bigquery/v2/projects/kaggle-161607/queries/fdc91d96-2162-4e88-895e-7b0e2ffc377e?maxResults=0&location=US: Query exceeded limit for bytes billed: 10000000000. 25131220992 or higher required.

但是,当我按如下所示替换 answers_query 时,没有错误:

However when I just replace my answers_query as follows there is no error:

answers_query = """
                SELECT a.id, a.body, a.owner_user_id
                FROM `bigquery-public-data.stackoverflow.posts_questions` AS q 
                INNER JOIN `bigquery-public-data.stackoverflow.posts_answers` AS a
                    ON q.id = a.parent_id
                WHERE q.tags LIKE '%bigquery%'
                """

似乎不同的缩进会产生不同的结果.我是SQL的新手,所以不知道缩进是否重要.从谷歌搜索和其他堆栈溢出的答案来看,缩进似乎是可读性的问题,不应更改.

It seems like different indentation is producing different results. I'm extremely new to SQL so I don't know if indentation should matter. From googling and other stack overflow answers it seems indentation is a matter of readability and it shouldn't change things.

推荐答案

我在Kaggle.com上也遇到过类似的问题.Kaggle.com在线编辑器以自己的方式解释语法.有时kaggle解释器解释错误.基本上kaggle ide主要是为了支持python.那就是为什么在kaggle在线IDE中有些时间缩进很重要

I had also similar kind of problem on Kaggle.com. Kaggle.com online editor interpret syntax in their own way.sometime kaggle interpreter intrpret wrongly. basically kaggle ide primarly targeted to support python. thats why some time indentation matters in kaggle online IDE

这篇关于缩进在SQL中重要吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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