code stringlengths 3 6.57k |
|---|
sqlContext.getConf("spark.sql.shuffle.partitions", u"10") |
self.sparkSession.conf.get(key, defaultValue) |
since("1.3.1") |
udf(self) |
UDFRegistration(self) |
since(1.4) |
range(self, start, end=None, step=1, numPartitions=None) |
value (exclusive) |
step (default: 1) |
sqlContext.range(1, 7, 2) |
collect() |
Row(id=1) |
Row(id=3) |
Row(id=5) |
sqlContext.range(3) |
collect() |
Row(id=0) |
Row(id=1) |
Row(id=2) |
self.sparkSession.range(start, end, step, numPartitions) |
since(1.2) |
registerFunction(self, name, f, returnType=StringType() |
function (including lambda function) |
sqlContext.registerFunction("stringLengthString", lambda x: len(x) |
sqlContext.sql("SELECT stringLengthString('test') |
collect() |
Row(stringLengthString(test) |
sqlContext.registerFunction("stringLengthInt", lambda x: len(x) |
IntegerType() |
sqlContext.sql("SELECT stringLengthInt('test') |
collect() |
Row(stringLengthInt(test) |
sqlContext.udf.register("stringLengthInt", lambda x: len(x) |
IntegerType() |
sqlContext.sql("SELECT stringLengthInt('test') |
collect() |
Row(stringLengthInt(test) |
self.sparkSession.catalog.registerFunction(name, f, returnType) |
TODO(andrew) |
_inferSchema(self, rdd, samplingRatio=None) |
sampling (default) |
self.sparkSession._inferSchema(rdd, samplingRatio) |
since(1.3) |
createDataFrame(self, data, schema=None, samplingRatio=None) |
schema (column names and types) |
typeName() |
sqlContext.createDataFrame(l) |
collect() |
Row(_1=u'Alice', _2=1) |
sqlContext.createDataFrame(l, ['name', 'age']) |
collect() |
Row(name=u'Alice', age=1) |
sqlContext.createDataFrame(d) |
collect() |
Row(age=1, name=u'Alice') |
sc.parallelize(l) |
sqlContext.createDataFrame(rdd) |
collect() |
Row(_1=u'Alice', _2=1) |
sqlContext.createDataFrame(rdd, ['name', 'age']) |
df.collect() |
Row(name=u'Alice', age=1) |
Row('name', 'age') |
rdd.map(lambda r: Person(*r) |
sqlContext.createDataFrame(person) |
df2.collect() |
Row(name=u'Alice', age=1) |
StructField("name", StringType() |
StructField("age", IntegerType() |
sqlContext.createDataFrame(rdd, schema) |
df3.collect() |
Row(name=u'Alice', age=1) |
sqlContext.createDataFrame(df.toPandas() |
collect() |
Row(name=u'Alice', age=1) |
sqlContext.createDataFrame(pandas.DataFrame([[1, 2]]) |
collect() |
Row(0=1, 1=2) |
sqlContext.createDataFrame(rdd, "a: string, b: int") |
collect() |
Row(a=u'Alice', b=1) |
rdd.map(lambda row: row[1]) |
sqlContext.createDataFrame(rdd, "int") |
collect() |
Row(value=1) |
sqlContext.createDataFrame(rdd, "boolean") |
collect() |
Traceback (most recent call last) |
self.sparkSession.createDataFrame(data, schema, samplingRatio) |
since(1.3) |
registerDataFrameAsTable(self, df, tableName) |
sqlContext.registerDataFrameAsTable(df, "table1") |
df.createOrReplaceTempView(tableName) |
since(1.6) |
dropTempTable(self, tableName) |
sqlContext.registerDataFrameAsTable(df, "table1") |
sqlContext.dropTempTable("table1") |
self.sparkSession.catalog.dropTempView(tableName) |
since(1.3) |
createExternalTable(self, tableName, path=None, source=None, schema=None, **options) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.