databricks

Generate Azure Databricks Token using Powershell script

牧云@^-^@ 提交于 2019-12-04 11:21:57
I need to generate Azure Databricks token using Powershell script. I am done with creation of Azure Databricks using ARM template , now i am looking to generate Databricks token using powershell script . Kindly let me know how to create Databricks token using Powershell script The only way to generate a new token is via the api which requires you to have a token in the first place. Or use the Web ui manually. There is no official powershell commands for databricks, there are some unofficial ones but they still require you to generate a token manually first. https://github.com/DataThirstLtd

DataFrame to RDD[(String, String)] conversion

℡╲_俬逩灬. 提交于 2019-12-04 06:32:17
问题 I want to convert an org.apache.spark.sql.DataFrame to org.apache.spark.rdd.RDD[(String, String)] in Databricks. Can anyone help? Background (and a better solution is also welcome): I have a Kafka stream which (after some steps) becomes a 2 column data frame. I would like to put this into a Redis cache, first column as a key and second column as a value. More specifically the type of the input is this: lastContacts: org.apache.spark.sql.DataFrame = [serialNumber: string, lastModified: bigint]

Call a function with each element a stream in Databricks

僤鯓⒐⒋嵵緔 提交于 2019-12-04 05:08:30
问题 I have a DataFrame stream in Databricks, and I want to perform an action on each element. On the net I found specific purpose methods, like writing it to the console or dumping into memory, but I want to add some business logic, and put some results into Redis. To be more specific, this is how it would look like in non-stream case: val someDataFrame = Seq( ("key1", "value1"), ("key2", "value2"), ("key3", "value3"), ("key4", "value4") ).toDF() def someFunction(keyValuePair: (String, String)) =

DATEDIFF in SPARK SQl

我与影子孤独终老i 提交于 2019-12-04 03:08:10
I am new to Spark SQL. We are migrating data from SQL server to Databricks. I am using SPARK SQL . Can you please suggest how to achieve below functionality in SPARK sql for the below datefunctions. I can see datediff gives only days in spark sql. DATEDIFF(YEAR,StartDate,EndDate) DATEDIFF(Month,StartDate,EndDate) DATEDIFF(Quarter,StartDate,EndDate) As you have mentioned SparkSQL does support DATEDIFF but for days only. I would also be careful as it seems the parameters are the opposite way round for Spark, ie --SQL Server DATEDIFF ( datepart , startdate , enddate ) --Spark DATEDIFF ( enddate ,

Specify multiple columns data type changes to different data types in pyspark

谁说我不能喝 提交于 2019-12-03 23:39:41
问题 I have a DataFrame ( df ) which consists of more than 50 columns and different types of data types, such as df3.printSchema() CtpJobId: string (nullable = true) |-- TransformJobStateId: string (nullable = true) |-- LastError: string (nullable = true) |-- PriorityDate: string (nullable = true) |-- QueuedTime: string (nullable = true) |-- AccurateAsOf: string (nullable = true) |-- SentToDevice: string (nullable = true) |-- StartedAtDevice: string (nullable = true) |-- ProcessStart: string

Is there a good way to join a stream in spark with a changing table?

妖精的绣舞 提交于 2019-12-03 15:51:18
Our Spark environment: DataBricks 4.2 (includes Apache Spark 2.3.1, Scala 2.11) What we try to achieve: We want to enrich streaming data with some reference data, which is updated regularly. The enrichment is done by joining the stream with the reference data. What we implemented: We implemented two spark jobs (jars): The first one is updating a Spark table TEST_TABLE every hour (let’s call it ‘reference data’) by using .write.mode(SaveMode.Overwrite).saveAsTable("TEST_TABLE") And afterwards calling spark.catalog.refreshTable("TEST_TABLE") The second job (let’s call it streaming data) is using

Azure Databricks vs ADLA for processing

假装没事ソ 提交于 2019-12-03 14:55:38
Presently, I have all my data files in Azure Data Lake Store. I need to process these files which are mostly in csv format. The processing would be running jobs on these files to extract various information for e.g.Data for certain periods of dates or certain events related to a scenario or adding data from multiple tables/files. These jobs run everyday through u-sql jobs in data factory(v1 or v2) and then sent to powerBI for visualization. Using ADLA for all this processing, I feel it takes a lot of time to process and seems very expensive. I got a suggestion that I should use Azure

Exploding nested Struct in Spark dataframe

末鹿安然 提交于 2019-12-03 10:47:56
I'm working through the Databricks example . The schema for the dataframe looks like: > parquetDF.printSchema root |-- department: struct (nullable = true) | |-- id: string (nullable = true) | |-- name: string (nullable = true) |-- employees: array (nullable = true) | |-- element: struct (containsNull = true) | | |-- firstName: string (nullable = true) | | |-- lastName: string (nullable = true) | | |-- email: string (nullable = true) | | |-- salary: integer (nullable = true) In the example, they show how to explode the employees column into 4 additional columns: val explodeDF = parquetDF

get datatype of column using pyspark

亡梦爱人 提交于 2019-12-03 05:34:28
We are reading data from MongoDB Collection . Collection column has two different values (e.g.: (bson.Int64,int) (int,float) ). I am trying to get a datatype using pyspark. My problem is some columns have different datatype. Assume quantity and weight are the columns quantity weight --------- -------- 12300 656 123566000000 789.6767 1238 56.22 345 23 345566677777789 21 Actually we didn't defined data type for any column of mongo collection. When I query to the count from pyspark dataframe dataframe.count() I got exception like this "Cannot cast STRING into a DoubleType (value: BsonString{value

How to increase the default precision and scale while loading data from oracle using spark-sql

懵懂的女人 提交于 2019-12-02 11:16:06
问题 Trying to load a data from oracle table where I have few columns hold floating point values , some times it holds upto DecimalType(40,20) i.e. 20 digits after point. Currently when I load its columns using var local_ora_df: DataFrameReader = ora_df; local_ora_df.option("partitionColumn", "FISCAL_YEAR") local_ora_df .option("schema",schema) .option("dbtable", query) .load() It is holding 10 digits after point i.e. decimal(38,10) (nullable = true) If I want to increase digits after point while