diff --git a/influxql/engine.go b/influxql/engine.go
index <HASH>..<HASH> 100644
--- a/influxql/engine.go
+++ b/influxql/engine.go
@@ -404,14 +404,14 @@ func (m *Mapper) run(e *Emitter) {
 			bufItr.tmax = tmin + m.interval - 1
 		}
 
-		// Execute the map function.
-		m.fn(bufItr, e, tmin)
-
 		// Exit if there was only one interval or no more data is available.
 		if bufItr.EOF() {
 			break
 		}
 
+		// Execute the map function.
+		m.fn(bufItr, e, tmin)
+
 		// Move the interval forward.
 		tmin += m.interval
 	}
Fix mapper to check if the iterator is EOF before calling the map function