Pyspark Sql Show Databases

With Oracle Database 11 g Release 2 (11. Though I've explained here with Scala, a similar method could be used to read from and write DataFrame to Parquet file using PySpark and if time permits I will cover it in future. It also provides an optimized API that can read the data from the various data source containing different files formats. I need to determine the 'coverage' of each of the columns, meaning, the fraction of rows that have non-NaN values for each column. Show Databases; Show Functions Shows a table's database and whether. This provides us the ability to create Databases and Tables across any of the associated clusters and notebooks. js: Find user by username LIKE value. I setup mine late last year, and my versions seem to be a lot newer than yours. Posted on November 27, 2017. 10/03/2019; 7 minutes to read +1; In this article. Pyspark DataFrames Example 1: FIFA World Cup Dataset. DataFrame is a special type of object, conceptually similar to a table in relational database. As per the Presto official documentation - Presto is an open source distributed SQL query engine for running i. April 21, from pyspark. The most obvious way to return the day, month and year from a date is to use the T-SQL functions of the same name. Pyspark is being utilized as a part of numerous businesses. Depending on your version of Scala, start the pyspark shell with a packages command line argument. A Scala, JDBC, and MySQL example. The goal of this post is to present an overview of some exploratory data analysis methods for machine learning and other applications in PySpark and Spark SQL. Stuck here "Failing Oozie Launcher, Main class [org. MIN() function with group by. The following are the features of Spark SQL: Integration With Spark Spark SQL queries are integrated with Spark programs. Comparison between AMAZON RDS and SQL Server on EC2; SQL Server Upgrade. PySpark dataframes can run on parallel architectures and even support SQL queries Introduction In my first real world machine learning problem , I introduced you to basic concepts of Apache Spark like how does it work, different cluster modes in Spark and What are the different data representation in Apache Spark. The Spark Python API (PySpark) exposes the Spark programming model to Python. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. In this section, you will learn how to manage databases in PostgreSQL including creating databases, modifying existing database’s features and deleting databases. 0 and later. The following magic functions are defined in the accompanying example code: %sql - return a Spark DataFrame for lazy evaluation of the SQL %sql_show - run the SQL statement and show max_show_lines (50) lines. Upon completing this lab you will be able to: - Program in Spark with the Python Language - Demonstrate how to read and process data using Spark - Compare and contrast RDD and Dataframes. View Srajan Nayak’s profile on LinkedIn, the world's largest professional community. We will learn PySpark SQL throughout the book. Spark SQL provides a great way of digging into PySpark, without first needing to learn a new library for dataframes. Find offerings for Developing SQL Databases (M20762). java and StoredProcedureMySQLSample. View akash soni’s profile on LinkedIn, the world's largest professional community. Pyspark DataFrames Example 1: FIFA World Cup Dataset. Note the use of the int() to cast for the employee ID as an integer. So: can we become our own "Northwind" for teaching SQL / databases? Having SO dump as a test database would be a huge benefit for any person learning SQL, because: Unlike Northwind, it's real data, not made up. On completing this book, you'll have ready-made code for all your PySpark SQL. Technology : Hadoop, Sqoop, Hive, JSON, MongoDB, SQL server,JDK 1. 0, you can easily read data from Hive data warehouse and also write/append new data to Hive tables. Using Sqoop, filtered data is transferred to structured database (like SQL server, MySQL). In order to check the connection between Spark SQL and Hive metastore, the verification of the list of Hive databases and tables using Hive prompt could be done. You can vote up the examples you like or vote down the ones you don't like. prints only default database. Using PySpark, the following script allows access to the AWS S3 bucket/directory used to exchange data between Spark and Snowflake. Apply to 305 Pyspark Jobs on Naukri. Select row terminator as {CR}{LF} and column terminator as comma{,} and click Next. Spark SQL Left Join. Did you know that you can execute R and Python code remotely in SQL Server from any IDE? This eliminates the need to move data around. SQL Server Management Studio (SSMS) provides the Export Wizard task which you can use to copy data from one data source to another. I uploaded the json data in DataBrick and wrote the commands as follows: df = sqlContext. The database can use either Microsoft Windows authentication or SQL Server authentication to determine how users can access the database. The document performs some typical PySpark functions, such as loading data from a CSV file and from the PostgreSQL database, performing some basic data analytics with Spark SQL, graphing the data. I just ran a simple JDBC connection and SQL SELECT test, and everything seems to work just as it does in Java. I have Cloudera CDH Quickstart 5. Out of the numerous ways to interact with Spark, the DataFrames API, introduced back in Spark 1. Data Quality Management (DQM) is the process of analyzing, defining, monitoring, and improving quality of data continuously. getOrCreate() spark = SparkSession(sc). PySpark SQL is a higher-level abstraction module over the PySpark Core. AWS Glue PySpark Transforms Reference. withColumn('2col', Fn(df. However, as of Oracle Database 10 g, external tables can also be written to. SQL/DWH Dev Zealic Solutions May 2019 – Present 7 months. Normally, in order to connect to JDBC data…. Not all databases speak SQL. So, if you see EXCEPT anywhere, just know it’s the same as MINUS but for a different database. Prior to Oracle Database 10 g, external tables were read-only. by David Taieb. Line 11) I run SQL to query my temporary view using Spark Sessions sql method. sql('select * from tiny_table') df_large = sqlContext. Learn how to use the SHOW DATABASES and SHOW SCHEMAS syntax of the Apache Spark SQL language in Databricks. I've tested this guide on a dozen Windows 7 and 10 PCs in different languages. I recorded a video to help them promote it, but I also learned a lot in the process, relating to how databases can be used in Spark. How to load JSON data in hive non-partitioned table using spark with the description of code and sample data. How to Use SQL with Python? In this section, the database connection with the python program is examined. May be its too late but never came across this before. In particular this process requires two steps where data is first converted from external type to row, and then from row to internal representation using generic RowEncoder. The following are code examples for showing how to use pyspark. Here are some good examples to show how to transform your data, feature engineering in PySpark. init('/home/pa. It provides a DataFrame API that simplifies and accelerates data manipulations. 3 : pyspark. *, dpt_data. In this demo, we will be using PySpark which is a Python library for Spark programming to read and write the data into SQL Server using Spark SQL. PySpark shell with Apache Spark for various analysis tasks. 10/03/2019; 7 minutes to read +1; In this article. On Linux, please change the path separator from \ to /. You can vote up the examples you like or vote down the ones you don't like. uri option when you connect to the pyspark shell. and external databases amenable to query federation. Apache Parquet Introduction. Database Services: Functionalities for database management and files(CVS, Excel) import/export to/from tables. How to Update Spark DataFrame Column Values using Pyspark? The Spark dataFrame is one of the widely used features in Apache Spark. We use cookies for various purposes including analytics. PySpark recipes¶ DSS lets you write recipes using Spark in Python, using the PySpark API. Note that if you want your application to support both Oracle and SQL Server databases, you can use ANSI SQL compliant CASE expression or COALESCE function that are supported by both Oracle and SQL Server: Oracle:. I need to determine the 'coverage' of each of the columns, meaning, the fraction of rows that have non-NaN values for each column. Menu PySpark connection with MS SQL Server 15 May 2018. As the name suggests, FILTER is used in Spark SQL to filter out records as per the requirement. There are various ways to connect to a database in Spark. When I run. Select Destination as Flat file Destination and browse for a. sql import SparkSession >>> spark = SparkSession \. sql('show databases'). Posted on November 27, 2017. Hive comes bundled with the Spark library as HiveContext, which inherits from SQLContext. Line 13) sc. As per the Presto official documentation - Presto is an open source distributed SQL query engine for running i. Imagine we would like to have a table with an id column describing a user and then two columns for the number of cats and dogs she has. Normally, in order to connect to JDBC data…. If the Python version is 2. PySpark SQL Recipes starts with recipes on creating dataframes from different types of data source, data aggregation and summarization, and exploratory data analysis using PySpark SQL. You can vote up the examples you like or vote down the ones you don't like. The question suggests a conceptual gap in understanding what Presto is and the role of Presto. sql import functions as F from pyspark. sql('select * from massive_table') df3 = df_large. I've tested this guide on a dozen Windows 7 and 10 PCs in different languages. Represents the table, view, type, procedure, function, package or synonym you wish to describe. QuickStart. PySpark - SQL Basics Learn Python for data science Interactively at www. Best Knowledge in Yii2, Codeignter, Laravel, Angular 2/4/5, Node JS, Express JS, Neo4j Database, Firebase Database and MySQL Database. AWS Glue has created the following transform Classes to use in PySpark ETL operations. PySpark is a Spark Python API that exposes the Spark programming model to Python - With it, you can speed up analytic applications. These snippets show how to make a DataFrame from scratch, using a list of values. 6, so we use the Spark SQL functionality to create DataFrames for exploration. Stuck here "Failing Oozie Launcher, Main class [org. More than 1 year has passed since last update. Pyspark DataFrame API can get little bit tricky especially if you worked with Pandas before - Pyspark DataFrame has some similarities with the Pandas version but there is significant difference in the APIs which can cause confusion. mysql>create database geo;. Instead of transferring large and sensitive data over the network or losing accuracy with sample csv files, you can have your R/Python code execute within your database. So, if you see EXCEPT anywhere, just know it’s the same as MINUS but for a different database. Spark is an analytics engine for big data processing. I want to get the database ower name (in format DOMAIN\user) by through T-SQL script. Spark SQL can also be used to read data from an existing Hive installation. js sql-server iphone regex ruby angularjs json swift django linux asp. You will start by getting a firm understanding of the Spark 2. To interact with a database you usually use SQL, the Structured Query Language. net ruby-on-rails objective-c arrays node. When starting the pyspark shell, you can specify: the --packages option to download the MongoDB Spark Connector package. SHOW SCHEMAS is a synonym for SHOW DATABASES. AWS Glue PySpark Transforms Reference. GroupedData Aggregation methods, returned by DataFrame. sql('select * from massive_table') df3 = df_large. df = sqlContext. I found that z=data1. urldecode, group by day and save the resultset into MySQL. The easy to use database connector that allows one-command operations between PySpark and PostgreSQL or ClickHouse databases. Spark Window Function - PySpark. A SparkSession can be used create a DataFrame, register DataFrame as tables, execute SQL over tables, cache tables, and even read parquet files. I've configured avamar and the sql agent for backing up a SQL2014 DAG on Windows 2012R2 but it seems i cannot see all my databases. Partial Indexes → A partial index is an index that only covers a subset of the rows in a table. key skills required are PySpark scripts, Python, Spark, Database (Azure SQL, SQL server) Knowledge…See this and similar jobs on LinkedIn. Spark SQL, part of Apache Spark big data framework, is used for structured data processing and allows running SQL like queries on Spark data. uri option when you connect to the pyspark shell. Line 11) I run SQL to query my temporary view using Spark Sessions sql method. SHOW SCHEMAS is a synonym for SHOW DATABASES. The external tables feature is a complement to existing SQL*Loader functionality. Console: Customized settings for engine parameters, task/engine management and resource isolation/display. Importing Data into Hive Tables Using Spark. On Linux, please change the path separator from \ to /. Line 13) sc. Show Databases — Databricks Documentation View Azure Databricks documentation Azure docs. You'll also discover how to solve problems in graph analysis using graphframes. Whether you're learning SQL for the first time or just need a refresher, read this article to learn when to use SELECT, JOIN, subselects, and UNION to access multiple tables with a single statement. Our SQL Commands reference will show you how to use the SELECT, DELETE, UPDATE, and WHERE SQL commands. Senior AWS Data Engineer - EMR/PySpark - Conshohocken - 140K+I am actively sourcing for an exciting…See this and similar jobs on LinkedIn. The script uses the standard AWS method of providing a pair of awsAccessKeyId and awsSecretAccessKey values. Hello community, Can someone let me know how to add multiple tables to a my query? As you can see from the code below I have two tables i) Person_Person ii) appl_stock. com DataCamp Learn Python for Data Science Interactively Initializing SparkSession Spark SQL is Apache Spark's module for working with structured data. It consists of about 1. The SQLContext encapsulate all relational functionality in Spark. For example: Select std_data. Line 11) I run SQL to query my temporary view using Spark Sessions sql method. sql("show tables in default") tableList = [x["tableName"] for x in df. Posted on November 27, 2017. Null column returned from a udf. Line 12) I use show to print the result. Learn how to connect an Apache Spark cluster in Azure HDInsight with an Azure SQL database and then read, write, and stream data into the SQL database. stop will stop the context – as I said it’s not necessary for pyspark client or notebooks such as Zeppelin. The uses of SCHEMAS and DATABASES are interchangeable – they mean the same thing. Stuck here "Failing Oozie Launcher, Main class [org. From Spark 2. You can write the left outer join using SQL mode as well. PySpark dataframes can run on parallel architectures and even support SQL queries Introduction In my first real world machine learning problem , I introduced you to basic concepts of Apache Spark like how does it work, different cluster modes in Spark and What are the different data representation in Apache Spark. In this tutorial, I show and share ways in which you can explore and employ five Spark SQL utility functions and APIs. What is Spark? Spark is a distributed in-memory cluster computing framework, pyspark, on the other hand, is an API developed in python for writing Spark applications in Python style. DataNoon - Making Big Data and Analytics simple! In this post, we will be discussing on how to perform different dataframe operations such as a aggregations, ordering, joins and other similar data manipulations on a spark dataframe. showはメソッドだと言っているだけです。実行するには. Here is the Python script to perform those actions:. GROUP BY typically also involves aggregates: COUNT, MAX, SUM, AVG, etc. Note that if you want your application to support both Oracle and SQL Server databases, you can use ANSI SQL compliant CASE expression or COALESCE function that are supported by both Oracle and SQL Server: Oracle:. Line 12) I use show to print the result. All MySQL tutorials are practical and easy-to-follow, with SQL script and screenshots available. I recorded a video to help them promote it, but I also learned a lot in the process, relating to how databases can be used in Spark. If i am taking a guess i can only see databases that do not appear in an availability group. SparkSession(sparkContext, jsparkSession=None)¶. PySpark SQL. The entry point to programming Spark with the Dataset and DataFrame API. stop will stop the context – as I said it’s not necessary for pyspark client or notebooks such as Zeppelin. We regularly publish useful MySQL tutorials to help web developers and database administrators learn MySQL faster and more effectively. Property spark. Use the SQL Database Browse feature from SQL Databases Page. Srajan has 4 jobs listed on their profile. Spark is a big data solution that has been proven to be easier and faster than Hadoop MapReduce. init('/home/pa. pyspark操作hive 4. They are extracted from open source Python projects. To create a basic instance, all we need is a SparkContext reference. Introduction to 7 PySpark SQL. It is an important tool to do statistics. com, India's No. With Oracle Database 11 g Release 2 (11. 1 on Windows, but it should work for Spark 2. In this article, Srini Penchikala discusses Spark SQL. Here is quick snippet.  DataFrames are composed of Row objects accompanied by a schema which describes the data types of each column. Just like SQL, you can join two dataFrames and perform various actions and transformations on Spark dataFrames. When you start Spark, DataStax Enterprise creates a Spark session instance to allow you to run Spark SQL queries against database tables. Apache Parquet Introduction. from pyspark. one is the filter method and the other is the where method. df = sqlContext. Spark is a big data solution that has been proven to be easier and faster than Hadoop MapReduce. PySpark dataframes can run on parallel architectures and even support SQL queries Introduction In my first real world machine learning problem , I introduced you to basic concepts of Apache Spark like how does it work, different cluster modes in Spark and What are the different data representation in Apache Spark. The Spark connector for Azure SQL Database and SQL Server enables SQL databases, including Azure SQL Database and SQL Server, to act as input data source or output data sink for Spark jobs. 0 architecture and how to set up a Python environment for Spark. What am I going to learn from this PySpark Tutorial? This spark and python tutorial will help you understand how to use Python API bindings i. SQLite is built into all mobile phones and most computers and comes bundled inside countless other applications that people use every day. Line 10) I group the users based on occupation. uri option when you connect to the pyspark shell. mysql>create database geo;. DataFrames are, in my opinion, a fantastic, flexible api that makes Spark roughly 14 orders of magnitude nicer to work with as opposed to RDDs. Pyspark ( Apache Spark with Python ) – Importance of Python. The four basic SQL joins described above let you tie the different pieces of data together, and allow you to start asking and answering more challenging questions about it. In this post, we will see how to replace nulls in a DataFrame with Python and Scala. DataFrames are provided by Spark SQL module, and they are used as primarily API for Spark’s Machine Learning lib and structured streaming modules. After installing and configuring PySpark, we can start programming using Spark in Python. 2, Databricks developments and unit testing in Jenkins pipeline, Weblogic Administrator 11g, Oracle 9i/10g/11g/12c Database Administrator with working experience in DevOps automation (using Github,Bitbucket,SVN,Jenkins,Nginx, Ansible, PL/SQL and Unix shell scripting. Spark is a big data solution that has been proven to be easier and faster than Hadoop MapReduce. Topic: this post is about a simple implementation with examples of IPython custom magic functions for running SQL in Apache Spark using PySpark and Jupyter notebooks. * from std_data left join dpt_data on(std_data. Pyspark DataFrames Example 1: FIFA World Cup Dataset. May be its too late but never came across this before. Spark SQL Left Join. PySpark has a DataFrame functionality. You’ll also discover how to solve problems in graph analysis using graphframes. csv file into pyspark dataframes ?" -- there are many ways to do this; the simplest would be to start up pyspark with Databrick's spark-csv module. [Raju Kumar Mishra; Sundar Rajan Raman] -- Carry out data analysis with PySpark SQL, graphframes, and graph data processing using a problem-solution approach. mysql>create database geo;. At Dataquest, we've released an interactive course on Spark, with a focus on PySpark. Find offerings for Developing SQL Databases (M20762). Here is the Python script to perform those actions:. When you start Spark, DataStax Enterprise creates a Spark session instance to allow you to run Spark SQL queries against database tables. How to get List names of all tables in SQL Server , MySQL and Oracle. April 21, from pyspark. Here are some good examples to show how to transform your data, feature engineering in PySpark. The entry point into all SQL functionality in Spark is the SQLContext class. It’s built-in in PySpark, which. Spark SQL Left Join. Spark is a quintessential part of the Apache data stack: built atop of Hadoop, Spark is intended to handle resource-intensive jobs such as data streaming and graph processing. As the name suggests, FILTER is used in Spark SQL to filter out records as per the requirement. Imagine we would like to have a table with an id column describing a user and then two columns for the number of cats and dogs she has. Learn how to connect an Apache Spark cluster in Azure HDInsight with an Azure SQL database and then read, write, and stream data into the SQL database. A SparkSession can be used create DataFrame, register DataFrame as tables, execute SQL over tables, cache tables, and read parquet files. You can vote up the examples you like or vote down the ones you don't like. sql import Row. We use cookies for various purposes including analytics. All Spark RDD operations usually work on dataFrames. Line 12) sc. There are various ways to connect to a database in Spark. It allows the creation of DataFrame objects as well as the execution of SQL queries. Tableau has a connection for Spark SQL, a feature of Spark that allows users and programs to query tables. See the complete profile on LinkedIn and discover akash’s connections and jobs at similar companies. Are you a programmer looking for a powerful tool to work on Spark? If yes, then you must take PySpark SQL into consideration. Using PySpark, the following script allows access to the AWS S3 bucket/directory used to exchange data between Spark and Snowflake. To read the contents of the DataFrame, use the show() method. EXCEPT is the same as MINUS – they both show results from one query that don’t exist in another query. Note: this was tested for Spark 2. The data type string format equals to pyspark. DateFormatClass takes the expression from dateExpr column and format. It allows you to utilize real time transactional data in big data analytics and persist results for. For example, if you define a udf function that takes as input two numbers a and b and returns a / b, this udf function will return a float (in Python 3). stop will stop the context - as I said it's not necessary for pyspark client or notebooks such as Zeppelin. How to get List names of all tables in SQL Server , MySQL and Oracle. The entry point into all SQL functionality in Spark is the SQLContext class. AnalysisException: u"Database 'test' not found;" - Only default hive database is visible Solved Go to solution. columns = new_column_name_list However, the same doesn't work in pyspark dataframes created using sqlContext. View akash soni’s profile on LinkedIn, the world's largest professional community. Repartition is the process of movement of data on the basis of some column or expression or random into required number of partitions. SQL Server Management Studio (SSMS) provides the Export Wizard task which you can use to copy data from one data source to another. PySpark recipes¶ DSS lets you write recipes using Spark in Python, using the PySpark API. Posted 1 month ago. PySparkSQL introduced the DataFrame, a tabular representation of structured data that is similar to that of a table from a relational database management system. Get this from a library! PySpark SQL Recipes : with HiveQL, Dataframe and Graphframes. It is easier to read in JSON than CSV files because JSON is self-describing, allowing Spark SQL to infer the appropriate schema without additional hints. The database can use either Microsoft Windows authentication or SQL Server authentication to determine how users can access the database. Spark SQL - DataFrames - A DataFrame is a distributed collection of data, which is organized into named columns. sqlContext. net ruby-on-rails objective-c arrays node. 7 or higher, you can utilize the pandas package. If you are already familiar with Apache Spark and Jupyter notebooks you may want to go directly to the example notebook and code. PySpark SQL is a higher-level abstraction module over the PySpark Core. sql import functions as F from pyspark. js sql-server iphone regex ruby angularjs json swift django linux asp. Show Databases — Databricks Documentation View Azure Databricks documentation Azure docs. It also provides an optimized API that can read the data from the various data source containing different files formats. csv file and click Next. Topic: this post is about a simple implementation with examples of IPython custom magic functions for running SQL in Apache Spark using PySpark and Jupyter notebooks. Querying database data using Spark SQL in Scala. a frame corresponding to the current row; return a new value to for each row by an aggregate/window function; Can use SQL grammar or. Instead of transferring large and sensitive data over the network or losing accuracy with sample csv files, you can have your R/Python code execute within your database. Unlike the basic Spark RDD API, the interfaces provided by Spark SQL provide Spark with more information about the structure of both the data and the computation being performed. sql('select * from tiny_table') df_large = sqlContext. js: Find user by username LIKE value. Prior to Oracle Database 10 g, external tables were read-only. The entry point to programming Spark with the Dataset and DataFrame API. show()としなければなりません。 spark. Cheat sheet for Spark Dataframes (using Python). The above operation writes to the MongoDB database and collection specified in the spark. Learning Outcomes. Here are some good examples to show how to transform your data, feature engineering in PySpark. PySpark is a particularly flexible tool for exploratory big data analysis because it integrates with the rest of the Python data analysis ecosystem, including pandas (DataFrames), NumPy (arrays), and Matplotlib (visualization). In this tutorial we are going to make first application "PySpark Hello World". sql('select * from massive_table') df3 = df_large. js: Find user by username LIKE value. If the Python version is 2. The pyspark interpreter is used to run program by typing it on console and it is executed on the Spark cluster. The fact-checkers, whose work is more and more important for those who prefer facts over lies, police the line between fact and falsehood on a day-to-day basis, and do a great job. Today, my small contribution is to pass along a very good overview that reflects on one of Trump’s favorite overarching falsehoods. Namely: Trump describes an America in which everything was going down the tubes under  Obama, which is why we needed Trump to make America great again. And he claims that this project has come to fruition, with America setting records for prosperity under his leadership and guidance. “Obama bad; Trump good” is pretty much his analysis in all areas and measurement of U.S. activity, especially economically. Even if this were true, it would reflect poorly on Trump’s character, but it has the added problem of being false, a big lie made up of many small ones. Personally, I don’t assume that all economic measurements directly reflect the leadership of whoever occupies the Oval Office, nor am I smart enough to figure out what causes what in the economy. But the idea that presidents get the credit or the blame for the economy during their tenure is a political fact of life. Trump, in his adorable, immodest mendacity, not only claims credit for everything good that happens in the economy, but tells people, literally and specifically, that they have to vote for him even if they hate him, because without his guidance, their 401(k) accounts “will go down the tubes.” That would be offensive even if it were true, but it is utterly false. The stock market has been on a 10-year run of steady gains that began in 2009, the year Barack Obama was inaugurated. But why would anyone care about that? It’s only an unarguable, stubborn fact. Still, speaking of facts, there are so many measurements and indicators of how the economy is doing, that those not committed to an honest investigation can find evidence for whatever they want to believe. Trump and his most committed followers want to believe that everything was terrible under Barack Obama and great under Trump. That’s baloney. Anyone who believes that believes something false. And a series of charts and graphs published Monday in the Washington Post and explained by Economics Correspondent Heather Long provides the data that tells the tale. The details are complicated. Click through to the link above and you’ll learn much. But the overview is pretty simply this: The U.S. economy had a major meltdown in the last year of the George W. Bush presidency. Again, I’m not smart enough to know how much of this was Bush’s “fault.” But he had been in office for six years when the trouble started. So, if it’s ever reasonable to hold a president accountable for the performance of the economy, the timeline is bad for Bush. GDP growth went negative. Job growth fell sharply and then went negative. Median household income shrank. The Dow Jones Industrial Average dropped by more than 5,000 points! U.S. manufacturing output plunged, as did average home values, as did average hourly wages, as did measures of consumer confidence and most other indicators of economic health. (Backup for that is contained in the Post piece I linked to above.) Barack Obama inherited that mess of falling numbers, which continued during his first year in office, 2009, as he put in place policies designed to turn it around. By 2010, Obama’s second year, pretty much all of the negative numbers had turned positive. By the time Obama was up for reelection in 2012, all of them were headed in the right direction, which is certainly among the reasons voters gave him a second term by a solid (not landslide) margin. Basically, all of those good numbers continued throughout the second Obama term. The U.S. GDP, probably the single best measure of how the economy is doing, grew by 2.9 percent in 2015, which was Obama’s seventh year in office and was the best GDP growth number since before the crash of the late Bush years. GDP growth slowed to 1.6 percent in 2016, which may have been among the indicators that supported Trump’s campaign-year argument that everything was going to hell and only he could fix it. During the first year of Trump, GDP growth grew to 2.4 percent, which is decent but not great and anyway, a reasonable person would acknowledge that — to the degree that economic performance is to the credit or blame of the president — the performance in the first year of a new president is a mixture of the old and new policies. In Trump’s second year, 2018, the GDP grew 2.9 percent, equaling Obama’s best year, and so far in 2019, the growth rate has fallen to 2.1 percent, a mediocre number and a decline for which Trump presumably accepts no responsibility and blames either Nancy Pelosi, Ilhan Omar or, if he can swing it, Barack Obama. I suppose it’s natural for a president to want to take credit for everything good that happens on his (or someday her) watch, but not the blame for anything bad. Trump is more blatant about this than most. If we judge by his bad but remarkably steady approval ratings (today, according to the average maintained by 538.com, it’s 41.9 approval/ 53.7 disapproval) the pretty-good economy is not winning him new supporters, nor is his constant exaggeration of his accomplishments costing him many old ones). I already offered it above, but the full Washington Post workup of these numbers, and commentary/explanation by economics correspondent Heather Long, are here. On a related matter, if you care about what used to be called fiscal conservatism, which is the belief that federal debt and deficit matter, here’s a New York Times analysis, based on Congressional Budget Office data, suggesting that the annual budget deficit (that’s the amount the government borrows every year reflecting that amount by which federal spending exceeds revenues) which fell steadily during the Obama years, from a peak of $1.4 trillion at the beginning of the Obama administration, to $585 billion in 2016 (Obama’s last year in office), will be back up to $960 billion this fiscal year, and back over $1 trillion in 2020. (Here’s the New York Times piece detailing those numbers.) Trump is currently floating various tax cuts for the rich and the poor that will presumably worsen those projections, if passed. As the Times piece reported: