Github user rmetzger commented on a diff in the pull request: https://github.com/apache/flink/pull/405#discussion_r24862039 --- Diff: flink-staging/flink-linq/src/main/scala/org/apache/flink/api/scala/expressions/package.scala --- @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.flink.api.scala + +import com.google.common.base.Preconditions +import org.apache.flink.api.expressions.{Row, ExpressionOperation} +import org.apache.flink.api.common.typeutils.CompositeType +import org.apache.flink.streaming.api.scala.DataStream + +import scala.language.implicitConversions + +/** + * == Language Integrated Queries (aka Expression Operations) == + * + * Importing this package with: + * + * {{{ + * import org.apache.flink.api.scala.expressions._ + * }}} + * + * imports implicit conversions for converting a [[DataSet]] or [[DataStream]] to an + * [[ExpressionOperation]]. This can be used to perform SQL-like queries on data. Please have + * a look at [[ExpressionOperation]] to see which operations are supported and + * [[org.apache.flink.api.scala.expressions.ImplicitExpressionOperations]] to see how an + * expression can be specified. + * + * Inside an expression operation you can use Scala Symbols to refer to field names. One would + * refer to field `a` by writing `'a`. Sometimes it is necessary to manually confert a + * Scala literal to an Expression Literal, in those cases use `Literal`, as in `Literal(3)`. + * + * Example: + * + * {{{ + * import org.apache.flink.api.scala._ + * import org.apache.flink.api.scala.expressions._ + * + * val env = ExecutionEnvironment.getExecutionEnvironment + * val input = env.fromElements(("Hello", 2), ("Hello", 5), ("Ciao", 3)) + * val result = input.as('word, 'count).groupBy('word).select('word, 'count.avg) + * result.print() + * + * env.execute() + * }}} + * + * The result of an [[ExpressionOperation]] can be converted back to the underlying API + * representation using `as`: + * + * {{{ + * case class Word(word: String, count: Int) + * + * val result = in.select(...).as('word, 'count) + * val set = result.as[Word] + * }}} + */ +package object expressions extends ImplicitExpressionConversions { + + implicit def dataSet2DataSetConversions[T](set: DataSet[T]): DataSetConversions[T] = { + Preconditions.checkArgument(set.getType.isInstanceOf[CompositeType[T]]) --- End diff -- I think we need a good error message here, telling the user why the type cannot be used with the expr lang.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---