concept county in category spark

appears as: county, county, counties, counties
Spark in Action, Second Edition

This is an excerpt from Manning's book Spark in Action, Second Edition.

Your first dataset comes from Wake County in North Carolina at http://mng.bz/ 5AM7 . It contains a list of restaurants in the county. The data can be downloaded directly from http://mng.bz/Jz2P .

Figure 12.4 Understanding the US Census Bureau’s id2 field: the two first digits indicate the state, and the last three indicate the county.

Similarly, to extract the county’s id , you can retrieve the modulo (rest of the division) by 1,000:

.withColumn( "countyId" , expr( "id%1000" ))

Listing 12.3 continues building the intermediate dataframe, by extracting the countyState array’s elements. Therefore, your dataset will not have nested elements but only linearized data to build, like a basic table. You see that the county (or parish in Louisiana) is the first (index 0) element of the countyState array, and the state is the second (index of 1) element in the same array.