GitHub user vundela opened a pull request:
https://github.com/apache/spark/pull/15003
[MINOR][SQL] Stripping extra new lines from the generator code
## What changes were proposed in this pull request?
Here is the simple unit test
test("Extra new lines in generated code") {
GeneratePredicate.generate(EqualTo(Literal(1), Literal(1)))
}
Generated code without fix
/* 001 */ public SpecificPredicate generate(Object[] references) {
/* 002 */ return new SpecificPredicate(references);
/* 003 */ }
/* 004 */
/* 005 */ class SpecificPredicate extends
org.apache.spark.sql.catalyst.expressions.codegen.Predicate {
/* 006 */ private final Object[] references;
/* 007 */
/* 008 */
/* 009 */
/* 010 */ public SpecificPredicate(Object[] references) {
/* 011 */ this.references = references;
/* 012 */
/* 013 */ }
/* 014 */
/* 015 */ public boolean eval(InternalRow i) {
/* 016 */
/* 017 */ boolean isNull = false;
/* 018 */
/* 019 */
/* 020 */ boolean value = false;
/* 021 */ value = 1 == 1;
/* 022 */ return !false && value;
/* 023 */ }
/* 024 */ }
Generated code with fix
/* 001 */ public SpecificPredicate generate(Object[] references) {
/* 002 */ return new SpecificPredicate(references);
/* 003 */ }
/* 004 */
/* 005 */ class SpecificPredicate extends
org.apache.spark.sql.catalyst.expressions.codegen.Predicate {
/* 006 */ private final Object[] references;
/* 007 */
/* 008 */ public SpecificPredicate(Object[] references) {
/* 009 */ this.references = references;
/* 010 */
/* 011 */ }
/* 012 */
/* 013 */ public boolean eval(InternalRow i) {
/* 014 */ boolean isNull = false;
/* 015 */
/* 016 */ boolean value = false;
/* 017 */ value = 1 == 1;
/* 018 */ return !false && value;
/* 019 */ }
/* 020 */ }
## How was this patch tested?
Manually tested the generated code and it strips the extra new lines.
(Please explain how this patch was tested. E.g. unit tests, integration
tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise,
remove this)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/vundela/spark master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15003.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #15003
----
commit 7ace69ec3cb06bee9fa87b08c3a2038d027e0506
Author: Srinivasa Reddy Vundela <[email protected]>
Date: 2016-09-07T21:04:42Z
[MINOR][SQL] Stripping extra new lines from the generator code
----
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]