Sto usando PySpark su Spark 1.5 su Cloudera YARN, usando Python 3.3 su Centos 6 Machines. L'istanza di SQL Server è SQL Server Enterprise a 64 bit. Il driver di SQL Server è elencato di seguito; sqljdbc4.jar; e ho aggiunto alla mia .bashrcPySpark 1.5 & MSSQL jdbc
export SPARK_CLASSPATH="/var/lib/spark/sqljdbc4.jar"
export PYSPARK_SUBMIT_ARGS="--conf spark.executor.extraClassPath="/var/lib/spark/sqljdbc4.jar" --driver-class-path="/var/lib/spark/sqljdbc4.jar" --jars="/var/lib/spark/sqljdbc4.jar" --master yarn --deploy-mode client"
E posso vedere la conferma quando lancio scintilla che
SPARK_CLASSPATH was detected (set to '/var/lib/spark/sqljdbc4.jar')
Ho un dataframe che assomiglia a questo schema
root
|-- daytetime: timestamp (nullable = true)
|-- ip: string (nullable = true)
|-- tech: string (nullable = true)
|-- th: string (nullable = true)
|-- car: string (nullable = true)
|-- min_dayte: timestamp (nullable = true)
|-- max_dayte: timestamp (nullable = true)
ho ho creato una tabella vuota già nel mio server MS SQL chiamato 'dbo.shaping', dove le 3 colonne di data/ora saranno datetime2 (7) e le altre nvarchar (50).
cerco di esportare il dataframe da PySpark utilizzare questo
properties = {"user": "<username>", "password": "<password>"}
df.write.format('jdbc').options(url='<IP>:1433/<dbname>', dbtable='dbo.shaping',driver="com.microsoft.sqlserver.jdbc.SQLServerDriver",properties=properties)
ottengo l'errore seguente traceback
Py4JError: An error occurred while calling o250.option. Trace:
py4j.Py4JException: Method option([class java.lang.String, class java.util.HashMap]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:333)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:342)
at py4j.Gateway.invoke(Gateway.java:252)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:207)
at java.lang.Thread.run(Thread.java:744)
sono i miei metodi almeno corretti, e forse questo errore è di scrivere il tipo specifico di dati, ad esempio, ho un problema con il costrutto di dati e non il mio codice?
Stai riesumare una domanda che è più di un anno di età. Hai verificato che sia ancora pertinente come richiesto (a fronte di cose come le versioni più recenti del software)? –
Gli aggiornamenti software non sono possibili su questo argomento. Deve essere la soluzione pyspark 1.5. – PR102012
pyspark 1.5 è una cosa, ma anche il driver Microsoft JDBC per SQL Server ha subito aggiornamenti. Il tuo errore ha tutti i tratti distintivi di una mancata corrispondenza di versione tra i componenti, non è abbastanza chiaro quali. Raccomando di elencare esplicitamente i numeri di versione di tutto ciò che state usando (python, pyspark, driver JDBC, SQL Server, OS), altrimenti c'è poca speranza che qualcuno lo riproduca. (Questo è anche il motivo per cui sono scettico sul fatto che questo è "ampiamente applicabile a un vasto pubblico", ma non ho esperienza con pyspark.) –