Body(String)という名前のデータフレーム列があります。本文列のデータは次のようになりますSpark UDF内でXML文字列を処理して構造体フィールドを返す
<p>I want to use a track-bar to change a form's opacity.</p>
<p>This is my code:</p>
<pre><code>decimal trans = trackBar1.Value/5000;
this.Opacity = trans;
</code></pre>
<p>When I build the application, it gives the following error:</p>
<blockquote>
<p>Cannot implicitly convert type 'decimal' to 'double'.</p>
</blockquote>
<p>I tried using <code>trans</code> and <code>double</code> but then the
control doesn't work. This code worked fine in a past VB.NET project. </p>
,While applying opacity to a form should we use a decimal or double value?
本文を使用しています。コードとテキストを別々に2つ用意します。コードはcodeという名前の要素の間にあり、textは他のすべてです。
私はこれが機能していません。この
case class bodyresults(text:String,code:String)
val Body:String=>bodyresults=(body:String)=>{ val xmlbody=scala.xml.XML.loadString(body)
val code = (xmlbody \\ "code").toString;
val text = "I want every thing else as text. what should I do"
(text,code)
}
val bodyudf=udf(Body)
val posts5=posts4.withColumn("codetext",bodyudf(col("Body")))
のように見えるUDFを作成しました。私の質問は です。ご覧のとおり、データにルートノードはありません。私はまだスカラーXML解析を使用できますか? 2.コード以外のテキストをテキストに解析する方法。
何かが間違って私は
の予想される出力知らせてください私のコードに存在する場合:
(code,text)
code = decimal trans = trackBar1.Value/5000;this.Opacity = trans;trans double
text = everything else
もしあればエラー?期待される成果は? – philantrovert
スパークシェルでは、エラーメッセージが表示されません。 UDF本体に何か問題があります。 spark-shellは関数を作成していません。 – Makkena
よろしいですか。コードタグは複数の場所にあります。それらのすべて、あるいは 'pre '、すなわち' decimal trans = ... 'の中にあるものだけを望みますか? – philantrovert