You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Spark-SQL中显示列标题?(基于HDP 2.6.4沙箱环境)

How to Show Column Headers in Spark-SQL on HDP 2.6.4 Sandbox

Got it, let's get those missing column headers showing up in your Spark-SQL results—this is a quick fix using Spark's built-in configuration settings. Here are two straightforward ways to make it happen:

Method 1: Enable Headers When Launching Spark-SQL

When you start the Spark-SQL CLI from your HDP sandbox terminal, add the spark.sql.showColumnName=true configuration parameter to the launch command:

spark-sql --conf spark.sql.showColumnName=true

Once you’re in the Spark-SQL shell, re-run your join query, and you’ll see ID, Name, and Product_Name as the first row of your result set.

Method 2: Enable Headers Within an Active Session

If you’re already in a running Spark-SQL session and don’t want to restart it, just execute this SET command to turn on column headers immediately:

SET spark.sql.showColumnName=true;

After running this, re-execute your original query:

SELECT Customers.ID, Name, Product_Name FROM Customers JOIN Orders WHERE Customers.ID = Orders.Customer_ID;

Your results will now include the column headers at the top, just like you want.

Bonus: Make Results Easier to Read

Your sample output shows all data run together—you can also adjust the truncation setting to display each row on its own line:

SET spark.sql.repl.eagerEval.truncate=100;

This will clean up the output format so you can scan results more easily.

A quick note: HDP 2.6.4 uses Spark 2.2.x under the hood, and these configuration settings are fully supported in this version.

内容的提问来源于stack exchange,提问作者Kai Chaza

火山引擎 最新活动