title: Is it possible to easily create a Kudu table from a PySpark Dataframe?
body: <p>Ideally the following code snipped would work:    </p>
  
  <pre><code>import kudu 
  from kudu.client import Partitioning
  
  df = … #some spark dataframe 
  
  # Connect to Kudu master server 
  client = kudu.connect(host=‘…‘, port=7051)
  
  # infer schema from spark dataframe
  schema = df.schema 
  
  # Define partitioning schema 
  partitioning = Partitioning().add_hash_partitions(column_names=['key'], num_buckets=3) 
  
  # Create new table 
  client.create_table('dev.some_example', schema, partitioning)
  </code></pre>
  
  <p>But the client.create_table expects a kudu.schema.Schema and not a struct from the dataframe. However in Scala you can do this (from <a href="https://kudu.apache.org/docs/developing.html" rel="nofollow noreferrer">https://kudu.apache.org/docs/developing.html</a>):</p>
  
  <pre><code>kuduContext.createTable(
  "dev.some_example", df.schema, Seq("key"),
  new CreateTableOptions()
      .setNumReplicas(1)
      .addHashPartitions(List("key").asJava, 3))
  </code></pre>
  
  <p>Now I was wondering if I can do the same with PySpark without manually defining each column with the kudu schema builder? </p>