If you follow Warren Buffett's warning on Walmart stock, you might look past the retailer's earnings pop on Thursday and find better stocks for your money. Buffett's Berkshire Hathaway is a long-time Walmart shareholder, but in 2016 it sold a large chunk of its stake, then valued around $3 billion. At that time, Buffett cited fellow billionaire Jeff Bezos, Amazon and the pressures ecommerce had created in the retail sector.

Warren Buffett, one of the most successful investors in the world Adam Jeffery | CNBC

Walmart shares have done very well since then. In the second half of 2016, when Berkshire was selling, Walmart was trading near $70. Even though its shares are basically flat so far this year, Walmart is now trading close to $100, with a 10 percent post-earnings gain on Thursday. Berkshire still held roughly 1.4 million shares of Walmart at the end of June, valued at roughly $140 million. Was it a mistake to get out? Buffett didn't bash Walmart when he sold — in fact, he had plenty of good things to say about the company. Berkshire's wholly owned retail distributor subsidiary, McLane, has a key business relationship with Walmart. Berkshire bought McLane from Walmart decades ago and still has to negotiate pricing agreements with the retail giant — negotiations that have become even tougher in the Amazon era. "Walmart is a fabulous company and what Sam Walton and his successors did is one of the great stories of American business," Buffett told CNBC in 2016. But the investing great stated his case pretty simply in recent years, based on CNBC interviews and Berkshire shareholder meeting commentary culled from CNBC's new Buffett archive: Retail is rough as long as Amazon is growing. There are less worrisome ways to put money to work in the stock market: "Retailing is too tough for me," he said in the 2016 interview after Berkshire sold the majority of its Walmart stake. "I've been in various things in retailing...and got my head handed to me." He added, "The online thing is very hard to figure out. ... I just decided I would look for a little easier game." Berkshire has done very well with Apple, its biggest tech bet since the IBM mistake. It has also made some well-timed deep value plays, such as Teva Pharmaceuticals. Walmart's earnings report on Thursday did show strength in online sales, but also was a read on the strength of U.S. consumer spending at this moment in the economic cycle and after the tax cuts, which have boosted earnings for other retailers this season, such as Home Depot.

Buffett has remarked in the past on how well Walmart has done in online sales in response to the Amazon threat. A former top Amazon executive, Marc Lore, is now running Walmart's ecommerce business after its acquisition of Jet.com. One strength in particular that he cited was having stores all over the country that can act as pick-up spots for online customers. This month, Amazon announced a similar grocery pickup service at its Whole Foods stores, following Walmart's lead. Walmart also is integrating its acquisition of India ecommerce company Flipkart.

Just as Walmart was once totally underestimated by the seers of its time, the idea some guy in Bentonville, Arkansas, would would take them to cleaners, that was the situation at first with traditional retailers, and Amazon. You want to be underestimated at first. Warren Buffett Berkshire Hathaway CEO and chairman

But speaking to CNBC in 2016, Buffett pointed to a number that scared him: Walmart's total global online sales was roughly in line with the annual gains that Amazon was making. "Worldwide you're talking maybe $12 billion to $14 billion. ... Amazon is having annual gains of numbers like that." According to a July forecast from consulting group eMarketer, Amazon has over 49 percent of the U.S. online retail market. It estimated Walmart's share at 3.7 percent, slightly below the share held by eBay and recent Buffett stock buy Apple, at 3.9 percent. Back in 2015, well before he sold most of the stake, Buffett was clear about the threat Amazon presented. "Ecommerce has to be enormously important to them, it's a game that they've got to become very, very competitive in." Walmart said U.S. online sales climbed 40 percent during the second quarter, and the company is still anticipating an increase of 40 percent for the full year. But that is down from a 50 percent jump logged in the third quarter of last year. When asked by CNBC at a time when Walmart was exerting pricing pressure on suppliers like McLane, Buffet remarked on similarities between Walmart and Amazon, similarities which have favored Amazon in the past decade. "Just as Walmart was once totally underestimated by the seers of its time, the idea some guy in Bentonville, Arkansas, would would take them to cleaners, that was the situation at first with traditional retailers, and Amazon. You want to be underestimated at first." "Jeff Bezos has built extraordinary economic machine from standing still, a start of zero, with competitors with lots of capital."

Is Walmart being underestimated by Buffett — again?